From 6b062ea01f6b4c38f47c63c7fb5600f5dae9060f Mon Sep 17 00:00:00 2001
From: Alexander Schlemmer <alexander@mail-schlemmer.de>
Date: Mon, 22 Nov 2021 16:00:14 +0100
Subject: [PATCH] STY: style cleanups

---
 setup.cfg                               |  5 +++-
 src/newcrawler/identifiable_adapters.py | 31 ++++++++++---------------
 src/newcrawler/stores.py                |  1 -
 src/newcrawler/structure_elements.py    |  2 --
 4 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/setup.cfg b/setup.cfg
index 88826f71..b14cc72a 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 9802e066..ab398fc5 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 237297b0..b85b14fe 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 17b2767a..df0d85f9 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 """
 
-- 
GitLab