From 36970eaa240e56fb114f89ee5b3dd4c3db70715a Mon Sep 17 00:00:00 2001
From: Alexander Schlemmer <alexander@mail-schlemmer.de>
Date: Fri, 18 Feb 2022 11:08:31 +0100
Subject: [PATCH] MAINT: some refactorings

---
 src/caosdb/high_level_api.py | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/caosdb/high_level_api.py b/src/caosdb/high_level_api.py
index 50d79521..001fe9a2 100644
--- a/src/caosdb/high_level_api.py
+++ b/src/caosdb/high_level_api.py
@@ -270,6 +270,21 @@ class CaosDBPythonRecordType(CaosDBPythonEntity):
 class CaosDBPythonProperty(CaosDBPythonEntity):
     pass
 
+class CaosDBPythonParent(object):
+    """
+    Parents can be either given by name or by ID.
+
+    When resolved, both fields should be set.
+    """
+
+    def __init__(self, id=None, name=None):
+        self.id = id
+        self.name = name
+
+class CaosDBPythonUnresolvedReference(object):
+
+    def __init__(self, id=None):
+        self.id = id
 
 class CaosDBPythonFile(CaosDBPythonEntity):
     def get_File(self, target=None):
@@ -311,16 +326,10 @@ def _single_convert_to_entity(entity, robj, recursive_depth, **kwargs):
     children = []
 
     for parent in robj._parents:
-        if sys.version_info[0] < 3:
-            if hasattr(parent, "encode"):
-                entity.add_parent(name=parent)
-            else:
-                entity.add_parent(id=parent)
+        if hasattr(parent, "encode"):
+            entity.add_parent(name=parent)
         else:
-            if hasattr(parent, "encode"):
-                entity.add_parent(name=parent)
-            else:
-                entity.add_parent(id=parent)
+            entity.add_parent(id=parent)
 
     def add_property(entity, prop, name, _recursive=False, datatype=None):
         if datatype is None:
-- 
GitLab