diff --git a/src/caosdb/apiutils.py b/src/caosdb/apiutils.py index 6602ca446d84d12944e752134d2b41ce25f8d75e..15f98d5c02f743fdffa4bfd5774192fe19b401aa 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)