From 2c57c5e64468561995c4bf6b995ee553e17d080b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Sun, 13 Nov 2022 15:52:46 +0100
Subject: [PATCH] wip

---
 src/caoscrawler/identifiable_adapters.py | 70 ++++++++++--------------
 1 file changed, 30 insertions(+), 40 deletions(-)

diff --git a/src/caoscrawler/identifiable_adapters.py b/src/caoscrawler/identifiable_adapters.py
index 4b2d2ffc..9be46973 100644
--- a/src/caoscrawler/identifiable_adapters.py
+++ b/src/caoscrawler/identifiable_adapters.py
@@ -161,56 +161,46 @@ class IdentifiableAdapter(metaclass=ABCMeta):
         identifiable
         """
 
-        path = None
-        if record.role == "File":
-            path = record.path
-
         registered_identifiable = self.get_registered_identifiable(record)
 
-        if registered_identifiable is None:
-            if path is not None:
-                return Identifiable(path=path)
-            return None
-        if len(registered_identifiable.parents) != 1:
-            raise RuntimeError("Multiple parents for identifiables"
-                               "not supported.")
         property_name_list_A = []
         property_name_list_B = []
         identifiable_props = {}
 
-        # fill the values:
-        for prop in registered_identifiable.properties:
-            if prop.name == "name":
-                # The name can be an identifiable, but it isn't a property
-                continue
-            # problem: what happens with multi properties?
-            # case A: in the registered identifiable
-            # case B: in the identifiable
-
-            record_prop = record.get_property(prop.name)
-            if record_prop is None:
-                # TODO: how to handle missing values in identifiables
-                #       raise an exception?
-                raise NotImplementedError(
-                    f"The following record is missing an identifying property:"
-                    f"RECORD\n{record}\nIdentifying PROPERTY\n{prop.name}"
-                )
-            identifiable_props[record_prop.name] = record_prop.value
-            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)):
-            raise RuntimeError(
-                "Multi properties used in identifiables could cause unpredictable results and are"
-                " not allowed. You might want to consider a Property with a list as value.")
+        if registered_identifiable is not None:
+            # fill the values:
+            for prop in registered_identifiable.properties:
+                if prop.name == "name":
+                    # The name can be an identifiable, but it isn't a property
+                    continue
+                # problem: what happens with multi properties?
+                # case A: in the registered identifiable
+                # case B: in the identifiable
+
+                record_prop = record.get_property(prop.name)
+                if record_prop is None:
+                    # TODO: how to handle missing values in identifiables
+                    #       raise an exception?
+                    raise NotImplementedError(
+                        f"The following record is missing an identifying property:"
+                        f"RECORD\n{record}\nIdentifying PROPERTY\n{prop.name}"
+                    )
+                identifiable_props[record_prop.name] = record_prop.value
+                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)):
+                raise RuntimeError(
+                    "Multi properties used in identifiables could cause unpredictable results and are"
+                    " not allowed. You might want to consider a Property with a list as value.")
 
         return Identifiable(record_type=registered_identifiable.parents[0].name,
                             name=record.name,
                             properties=identifiable_props,
-                            path=path
+                            path=record.path
                             )
 
     @abstractmethod
-- 
GitLab