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
No related branches found
No related tags found
2 merge requests!57RELEASE 0.7.3,!45F copy entity
Pipeline #21648 passed
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment