Skip to content
Snippets Groups Projects
Commit 02c51e90 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: rename variable to more meaningful version

parent bd38843d
Branches
Tags
No related merge requests found
...@@ -484,18 +484,18 @@ def getCommitIn(folder): ...@@ -484,18 +484,18 @@ def getCommitIn(folder):
COMPARED = ["name", "role", "datatype", "description", "importance"] COMPARED = ["name", "role", "datatype", "description", "importance"]
def compare_entities(r1, r2): def compare_entities(old_entity, new_entity):
description = "" description = ""
# if r1 is r2: # if old_entity is new_entity:
# return description # return description
for attr in COMPARED: for attr in COMPARED:
try: try:
r1.__getattribute__(attr) old_entity.__getattribute__(attr)
r1_attr_exists = True r1_attr_exists = True
except BaseException: except BaseException:
r1_attr_exists = False r1_attr_exists = False
try: try:
r2.__getattribute__(attr) new_entity.__getattribute__(attr)
r2_attr_exists = True r2_attr_exists = True
except BaseException: except BaseException:
r2_attr_exists = False r2_attr_exists = False
...@@ -504,22 +504,22 @@ def compare_entities(r1, r2): ...@@ -504,22 +504,22 @@ def compare_entities(r1, r2):
continue continue
if not r1_attr_exists and not r2_attr_exists: if not r1_attr_exists and not r2_attr_exists:
continue continue
if r1.__getattribute__(attr) != r2.__getattribute__(attr): if old_entity.__getattribute__(attr) != new_entity.__getattribute__(attr):
description += attr + " differs:\n" description += attr + " differs:\n"
description += str(r1.__getattribute__(attr)) + "\n" description += str(old_entity.__getattribute__(attr)) + "\n"
description += str(r2.__getattribute__(attr)) + "\n" description += str(new_entity.__getattribute__(attr)) + "\n"
# properties # properties
if (len(r1.properties) > 0) ^ (len(r2.properties) > 0): if (len(old_entity.properties) > 0) ^ (len(new_entity.properties) > 0):
description += "only one has properties\n" description += "only one has properties\n"
else: else:
for prop in r1.properties: for prop in old_entity.properties:
matching = [p for p in r2.properties if p.name == prop.name] matching = [p for p in new_entity.properties if p.name == prop.name]
if len(matching) == 0: if len(matching) == 0:
description += "r2 is missing the property '" + prop.name + "'\n" description += "new_entity is missing the property '" + prop.name + "'\n"
elif len(matching) == 1: elif len(matching) == 1:
if (r1.get_importance(prop.name) != if (old_entity.get_importance(prop.name) !=
r2.get_importance(prop.name)): new_entity.get_importance(prop.name)):
description += "importance of '" + prop.name + "' differs\n" description += "importance of '" + prop.name + "' differs\n"
if ((prop.datatype is not None and if ((prop.datatype is not None and
matching[0].datatype is not None) and matching[0].datatype is not None) and
...@@ -527,28 +527,28 @@ def compare_entities(r1, r2): ...@@ -527,28 +527,28 @@ def compare_entities(r1, r2):
description += "datatype of '" + prop.name + "' differs\n" description += "datatype of '" + prop.name + "' differs\n"
else: else:
raise NotImplementedError() raise NotImplementedError()
for prop in r2.properties: for prop in new_entity.properties:
if len([0 for p in r1.properties if p.name == prop.name]) == 0: if len([0 for p in old_entity.properties if p.name == prop.name]) == 0:
description += "r1 is missing the property '" + prop.name + "'\n" description += "old_entity is missing the property '" + prop.name + "'\n"
# parents # parents
if ((len(r1.parents) > 0) ^ (len(r2.parents) > 0)): if ((len(old_entity.parents) > 0) ^ (len(new_entity.parents) > 0)):
description += "only one has parents\n" description += "only one has parents\n"
else: else:
for par in r1.parents: for par in old_entity.parents:
matching = [p for p in r2.parents if p.name == par.name] matching = [p for p in new_entity.parents if p.name == par.name]
if len(matching) == 0: if len(matching) == 0:
description += "r2 is missing the parent '" + par.name + "'\n" description += "new_entity is missing the parent '" + par.name + "'\n"
elif len(matching) == 1: elif len(matching) == 1:
description += compare_entities(par, matching[0]) description += compare_entities(par, matching[0])
else: else:
raise NotImplementedError() raise NotImplementedError()
for par in r2.parents: for par in new_entity.parents:
if len([0 for p in r1.parents if p.name == par.name]) == 0: if len([0 for p in old_entity.parents if p.name == par.name]) == 0:
description += "r1 is missing the parent '" + par.name + "'\n" description += "old_entity is missing the parent '" + par.name + "'\n"
if description != "": if description != "":
description = """####################### description = """#######################
{} {}
#######################\n""".format(r1.name) + description #######################\n""".format(old_entity.name) + description
return description return description
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment