Skip to content
Snippets Groups Projects

Improving the compare_entities functions

2 files
+ 77
1
Compare changes
  • Side-by-side
  • Inline

Files

+ 9
1
@@ -267,7 +267,7 @@ def compare_entities(old_entity: Entity, new_entity: Entity,
continue
if ((old_entity_attr_exists != new_entity_attr_exists)
or (oldattr != newattr)):
or (oldattr != newattr)):
if old_entity_attr_exists:
olddiff[attr] = oldattr
@@ -278,8 +278,16 @@ def compare_entities(old_entity: Entity, new_entity: Entity,
# properties
for prop in old_entity.properties:
# Find the corresponding property in new_entity:
matching = [p for p in new_entity.properties if p.name == prop.name]
# This is needed for checking for multi properties in old_entity:
# TODO: is there a better way?
matching_old = [p for p in old_entity.properties if p.name == prop.name]
if len(matching_old) != 1:
raise NotImplementedError(
"Comparison not implemented for multi-properties.")
if len(matching) == 0:
olddiff["properties"][prop.name] = {}
elif len(matching) == 1:
Loading