diff --git a/setup.cfg b/setup.cfg index 88826f71b1563492d6f9780295d04b1c402b5550..b14cc72add8b6eed430a3bbf8549bbc886d36849 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,4 +20,7 @@ packages = find: python_requires = >=3.6 [options.packages.find] -where = src \ No newline at end of file +where = src + +[flake8] +per-file-ignores = __init__.py:F401 \ No newline at end of file diff --git a/src/newcrawler/identifiable_adapters.py b/src/newcrawler/identifiable_adapters.py index 9802e066d4f2b48366f2dac85801b7d0342fbd80..ab398fc5966c826e3ab656aa2c9e214360404be0 100644 --- a/src/newcrawler/identifiable_adapters.py +++ b/src/newcrawler/identifiable_adapters.py @@ -55,17 +55,17 @@ class IdentifiableAdapter(object): """ This function is taken from the old crawler: caosdb-advanced-user-tools/src/caosadvancedtools/crawler.py - + uses the properties of ident to create a query that can determine whether the required record already exists. """ - + if len(ident.parents) != 1: raise RuntimeError("Multiple parents for identifiables not supported.") - + query_string = "FIND Record " + ident.get_parents()[0].name query_string += " WITH " - + if ident.name is None and len(ident.get_properties()) == 0: raise ValueError( "The identifiable must have features to identify it.") @@ -76,13 +76,10 @@ class IdentifiableAdapter(object): for p in ident.get_properties(): if p.datatype is not None and p.datatype.startswith("LIST<"): for v in p.value: - query_string += ("references " - + str(v.id if isinstance(v, db.Entity) - else v) - + " AND ") + query_string += ("references " + str(v.id if isinstance(v, db.Entity) + else v) + " AND ") else: - query_string += ("'" + p.name + "'='" + str(get_value(p)) - + "' AND ") + query_string += ("'" + p.name + "'='" + str(get_value(p)) + "' AND ") # remove the last AND return query_string[:-4] @@ -94,7 +91,7 @@ class IdentifiableAdapter(object): """ pass - + def get_identifiable(self, record: db.Record): registered_identifiable = self.get_registered_identifiable(record) @@ -116,12 +113,12 @@ class IdentifiableAdapter(object): identifiable.add_property(record.get_property(prop.name)) property_name_list_A.append(prop.name) - + # check for multi properties in the record: for prop in property_name_list_A: property_name_list_B.append(prop) - if (len(set(property_name_list_B)) != len(property_name_list_B) or - len(set(property_name_list_A)) != len(property_name_list_A)): + if (len(set(property_name_list_B)) != len(property_name_list_B) or len( + set(property_name_list_A)) != len(property_name_list_A)): raise RuntimeError("Multi properties used in identifiables can cause unpredictable results.") return identifiable @@ -154,8 +151,6 @@ class IdentifiableAdapter(object): return identified_record - - class LocalStorageIdentifiableAdapter(IdentifiableAdapter): """ Identifiable adapter which can be used for unit tests. @@ -199,7 +194,7 @@ class LocalStorageIdentifiableAdapter(IdentifiableAdapter): if record.get_property(prop.name) is None: return False return True - + def get_registered_identifiable(self, record: db.Record): identifiable_candidates = [] for name, definition in self._registered_identifiables.items(): @@ -235,5 +230,3 @@ class LocalStorageIdentifiableAdapter(IdentifiableAdapter): if len(candidates) == 0: return None return candidates[0] - - diff --git a/src/newcrawler/stores.py b/src/newcrawler/stores.py index 237297b0f22db0c7138310733f93c41494ea829a..b85b14fe60abe5a24657aad687848a0159bb0368 100644 --- a/src/newcrawler/stores.py +++ b/src/newcrawler/stores.py @@ -23,7 +23,6 @@ # ** end header # -import caosdb as db from collections import defaultdict diff --git a/src/newcrawler/structure_elements.py b/src/newcrawler/structure_elements.py index 17b2767af18949182eb3c7a86987727a872ba528..df0d85f9181ff918ac2e80e355c9d18799e0781d 100644 --- a/src/newcrawler/structure_elements.py +++ b/src/newcrawler/structure_elements.py @@ -23,8 +23,6 @@ # ** end header # -from abc import abstractmethod - class StructureElement(object): """ base class for elements in the hierarchical data structure """