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

MAINT: some clean up

parent 6055192a
No related branches found
No related tags found
3 merge requests!91Release 0.3,!69Refactor Identifiable and caches,!67MAINT: introduce an identifiable class
Pipeline #30542 failed
......@@ -88,6 +88,7 @@ class Identifiable():
def _create_hashable_string(identifiable: Identifiable) -> str:
"""
creates a string from the attributes of an identifiable that can be hashed
String has the form "P<parent>N<name>a:5b:10"
"""
rec_string = "P<{}>N<{}>".format(identifiable.record_type, identifiable.name)
# TODO this structure neglects Properties if multiple exist for the same name
......@@ -100,18 +101,16 @@ class Identifiable():
"""
Identifiables are equal if they belong to the same Record. Since ID and path are on their
own enough to identify the Record it is sufficient if those attributes are equal.
1. both IDs are set (not None) -> equal if IDs are equal
2. both paths are set (not None) -> equal if paths are equal
3. equal if attribute representations are equal
"""
if not isinstance(other, Identifiable):
return False
if self.record_id is not None and self.record_id == other.record_id:
return True
elif (self.record_id is not None and other.record_id is not None
and self.record_id == other.record_id):
return False
elif self.path is not None and self.path == other.path:
return True
elif (self.path is not None and other.path is not None and self.path == other.id):
return False
raiser ValueError("Identifiable can only be compared to other Identifiable objects.")
elif self.record_id is not None and other.record_id is not None:
return self.record_id == other.record_id
elif self.path is not None and other.path is not None:
return self.path == other.path
elif self.get_representation() == other.get_representation():
return True
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment