From 465f41f21abed91c3d877f22af3f1cc7c28957f7 Mon Sep 17 00:00:00 2001
From: Alexander Schlemmer <alexander@mail-schlemmer.de>
Date: Tue, 12 Apr 2022 14:12:43 +0200
Subject: [PATCH] DOC: renamed COMAPRED to SPECIAL_ATTRIBUTES and added
 documentation

---
 src/caosdb/apiutils.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/caosdb/apiutils.py b/src/caosdb/apiutils.py
index 6602ca44..15f98d5c 100644
--- a/src/caosdb/apiutils.py
+++ b/src/caosdb/apiutils.py
@@ -565,8 +565,8 @@ def getCommitIn(folder):
         return t.readline().strip()
 
 
-COMPARED = ["name", "role", "datatype", "description",
-            "id", "path", "checksum", "size"]
+SPECIAL_ATTRIBUTES = ["name", "role", "datatype", "description",
+                      "id", "path", "checksum", "size"]
 
 
 def compare_entities(old_entity: Entity, new_entity: Entity):
@@ -592,7 +592,7 @@ def compare_entities(old_entity: Entity, new_entity: Entity):
     if old_entity is new_entity:
         return (olddiff, newdiff)
 
-    for attr in COMPARED:
+    for attr in SPECIAL_ATTRIBUTES:
         try:
             oldattr = old_entity.__getattribute__(attr)
             old_entity_attr_exists = True
@@ -686,6 +686,10 @@ def copy_entity(entity: Entity):
     Return a copy of entity.
 
     If deep == True return a deep copy, recursively copying all sub entities.
+
+    Standard properties are copied using add_property.
+    Special attributes, as defined by the global variable SPECIAL_ATTRIBUTES and additionaly
+    the "value" are copied using setattr.
     """
     print(entity)
     if entity.role == "File":
@@ -704,7 +708,7 @@ def copy_entity(entity: Entity):
     # Copy special attributes:
     # TODO: this might rise an exception when copying
     #       special file attributes like checksum and size.
-    for attribute in COMPARED + ["value"]:
+    for attribute in SPECIAL_ATTRIBUTES + ["value"]:
         val = getattr(entity, attribute)
         if val is not None:
             setattr(new, attribute, val)
-- 
GitLab