Skip to content
Snippets Groups Projects
Commit 465f41f2 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

DOC: renamed COMAPRED to SPECIAL_ATTRIBUTES and added documentation

parent 394d2f5d
Branches
Tags
2 merge requests!57RELEASE 0.7.3,!45F copy entity
Pipeline #21648 passed
...@@ -565,7 +565,7 @@ def getCommitIn(folder): ...@@ -565,7 +565,7 @@ def getCommitIn(folder):
return t.readline().strip() return t.readline().strip()
COMPARED = ["name", "role", "datatype", "description", SPECIAL_ATTRIBUTES = ["name", "role", "datatype", "description",
"id", "path", "checksum", "size"] "id", "path", "checksum", "size"]
...@@ -592,7 +592,7 @@ 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: if old_entity is new_entity:
return (olddiff, newdiff) return (olddiff, newdiff)
for attr in COMPARED: for attr in SPECIAL_ATTRIBUTES:
try: try:
oldattr = old_entity.__getattribute__(attr) oldattr = old_entity.__getattribute__(attr)
old_entity_attr_exists = True old_entity_attr_exists = True
...@@ -686,6 +686,10 @@ def copy_entity(entity: Entity): ...@@ -686,6 +686,10 @@ def copy_entity(entity: Entity):
Return a copy of entity. Return a copy of entity.
If deep == True return a deep copy, recursively copying all sub entities. 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) print(entity)
if entity.role == "File": if entity.role == "File":
...@@ -704,7 +708,7 @@ def copy_entity(entity: Entity): ...@@ -704,7 +708,7 @@ def copy_entity(entity: Entity):
# Copy special attributes: # Copy special attributes:
# TODO: this might rise an exception when copying # TODO: this might rise an exception when copying
# special file attributes like checksum and size. # special file attributes like checksum and size.
for attribute in COMPARED + ["value"]: for attribute in SPECIAL_ATTRIBUTES + ["value"]:
val = getattr(entity, attribute) val = getattr(entity, attribute)
if val is not None: if val is not None:
setattr(new, attribute, val) setattr(new, attribute, val)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment