Skip to content
Snippets Groups Projects
Verified Commit 365e2d3d authored by Daniel Hornung's avatar Daniel Hornung
Browse files

MAINT: Linting

parent 5f0ad95d
No related branches found
No related tags found
1 merge request!100WIP: Filling XLSX: Seems to be working.
Pipeline #49438 passed
......@@ -22,17 +22,7 @@
""" Imports labfolder exports """
import os
import re
import shutil
import subprocess
import sys
import tempfile
import time
import warnings
from io import BytesIO, StringIO
import requests
import yaml
from bs4 import BeautifulSoup
import caosdb as db
......@@ -73,8 +63,8 @@ def get_author_from_entry(entry):
def val_or_none(stuff):
if len(stuff) == 0:
return None
else:
return stuff[0].getText()
return stuff[0].getText()
def add_property_from_data_element(dbrecord, element):
......
......@@ -17,15 +17,15 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import caosdb as db
from caosadvancedtools.cfood import (AbstractFileCFood, assure_has_description,
assure_has_parent, assure_has_property,
assure_object_is_in_list, get_entity)
from caosadvancedtools.read_md_header import get_header
from caosadvancedtools.cfood import (AbstractFileCFood,
assure_has_property,
assure_object_is_in_list,
)
from .generic_pattern import full_pattern
from .utils import parse_responsibles, reference_records_corresponding_to_files
from .withreadme import DATAMODEL as dm
from .withreadme import RESULTS, REVISIONOF, SCRIPTS, WithREADME, get_glob
from .withreadme import RESULTS, REVISIONOF, WithREADME, get_glob
class ExperimentCFood(AbstractFileCFood, WithREADME):
......@@ -42,7 +42,10 @@ class ExperimentCFood(AbstractFileCFood, WithREADME):
super().__init__(*args, **kwargs)
WithREADME.__init__(self)
self.name_map = {},
self.name_map = ({}, )
self.experiment = None
self.people = None
self.project = None
@staticmethod
def get_re():
......
......@@ -16,18 +16,14 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import os
from itertools import chain
import caosdb as db
from caosadvancedtools.cfood import (AbstractFileCFood,
assure_object_is_in_list, fileguide,
get_entity)
)
from caosadvancedtools.read_md_header import get_header
from caosadvancedtools.utils import find_records_that_reference_ids
from .generic_pattern import date_suffix_pattern, readme_pattern
from .utils import (get_files_referenced_by_field, parse_responsibles,
from .utils import (parse_responsibles,
reference_records_corresponding_to_files)
from .withreadme import DATAMODEL as dm
from .withreadme import (RESULTS, REVISIONOF, SCRIPTS, SOURCES, WithREADME,
......@@ -37,16 +33,15 @@ from .withreadme import (RESULTS, REVISIONOF, SCRIPTS, SOURCES, WithREADME,
def folder_to_type(name):
if name == "Theses":
return "Thesis"
elif name == "Articles":
if name == "Articles":
return "Article"
elif name == "Posters":
if name == "Posters":
return "Poster"
elif name == "Presentations":
if name == "Presentations":
return "Presentation"
elif name == "Reports":
if name == "Reports":
return "Report"
else:
raise ValueError()
raise ValueError()
class PublicationCFood(AbstractFileCFood, WithREADME):
......@@ -58,6 +53,8 @@ class PublicationCFood(AbstractFileCFood, WithREADME):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
WithREADME.__init__(self)
self.people = None
self.publication = None
def collect_information(self):
self.find_referenced_files([RESULTS, SOURCES, SCRIPTS])
......
......@@ -20,17 +20,12 @@ import re
import caosdb as db
import pandas as pd
from caosadvancedtools.cfood import (AbstractFileCFood, assure_has_description,
assure_has_parent, assure_has_property,
assure_object_is_in_list, get_entity)
from caosadvancedtools.read_md_header import get_header
from caosadvancedtools.cfood import (AbstractFileCFood,
)
from ..cfood import assure_property_is, fileguide
from .experiment_cfood import ExperimentCFood
from .generic_pattern import date_pattern, date_suffix_pattern, project_pattern
from .utils import parse_responsibles, reference_records_corresponding_to_files
from .withreadme import DATAMODEL as dm
from .withreadme import RESULTS, REVISIONOF, SCRIPTS, WithREADME, get_glob
# TODO similarities with TableCrawler
......@@ -49,6 +44,9 @@ class ResultTableCFood(AbstractFileCFood):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.table = pd.read_csv(fileguide.access(self.crawled_path))
self.recs = []
self.experiment = None
self.project = None
@staticmethod
def get_re():
......@@ -60,7 +58,7 @@ class ResultTableCFood(AbstractFileCFood):
self.experiment, self.project = (
ExperimentCFood.create_identifiable_experiment(self.match))
for idx, row in self.table.iterrows():
for _, row in self.table.iterrows():
rec = db.Record()
rec.add_parent(self.match.group("recordtype"))
......@@ -77,10 +75,11 @@ class ResultTableCFood(AbstractFileCFood):
self.identifiables.extend([self.project, self.experiment])
def update_identifiables(self):
for ii, (idx, row) in enumerate(self.table.iterrows()):
for ii, (_, row) in enumerate(self.table.iterrows()):
for col in row.index:
match = re.match(ResultTableCFood.property_name_re, col)
assure_property_is(self.recs[ii], match.group("pname"), row.loc[col], to_be_updated=self.to_be_updated)
assure_property_is(self.recs[ii], match.group("pname"), row.loc[col],
to_be_updated=self.to_be_updated)
assure_property_is(self.experiment, self.match.group("recordtype"),
self.recs, to_be_updated=self.to_be_updated,
datatype=db.LIST(self.match.group("recordtype")))
......@@ -40,6 +40,9 @@ class SoftwareCFood(AbstractFileCFood, WithREADME):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
WithREADME.__init__(self)
self.people = None
self.software = None
self.softwareversion = None
def collect_information(self):
self.find_referenced_files([BINARIES, SOURCECODE])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment