Skip to content
Snippets Groups Projects

F fix compare entities branch2

Merged Alexander Schlemmer requested to merge f-fix-compare-entities-branch2 into dev
1 unresolved thread
Files
4
+ 24
1
@@ -561,7 +561,23 @@ def getCommitIn(folder):
COMPARED = ["name", "role", "datatype", "description", "importance"]
def compare_entities(old_entity, new_entity):
def compare_entities(old_entity: Entity, new_entity: Entity):
"""
Compare two entites.
Return a tuple of dictionaries, the first index belongs to additional information for old
entity, the second index belongs to additional information for new entity.
Additional information means in detail:
- Additional parents (a list under key "parents")
- Information about properties:
- Each property lists either an additional property or a property with a changed:
- ... datatype
- ... importance or
- ... value (not implemented yet)
In case of changed information the value listed under the respective key shows the
value that is stored in the respective entity.
"""
olddiff = {"properties": {}, "parents": []}
newdiff = {"properties": {}, "parents": []}
@@ -623,6 +639,13 @@ def compare_entities(old_entity, new_entity):
newdiff["properties"][prop.name]["datatype"] = \
matching[0].datatype
if ((prop.value is not None and
Please register or sign in to reply
matching[0].value is not None) and
(prop.value != matching[0].value)):
olddiff["properties"][prop.name]["value"] = prop.value
newdiff["properties"][prop.name]["value"] = \
matching[0].value
if (len(newdiff["properties"][prop.name]) == 0
and len(olddiff["properties"][prop.name]) == 0):
newdiff["properties"].pop(prop.name)
Loading