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

wip

parent 10b02c15
No related branches found
No related tags found
2 merge requests!178FIX: #96 Better error output for crawl.py script.,!167Sync Graph
...@@ -150,7 +150,7 @@ class SyncGraph(): ...@@ -150,7 +150,7 @@ class SyncGraph():
self.backward_id_referenced_by, self.backward_id_referenced_by,
) = self._create_reference_mapping(self.nodes) ) = self._create_reference_mapping(self.nodes)
# self._mark_entities_with_path_or_id() self._mark_entities_with_path_or_id()
def set_id_of_node(self, se: SyncNode, node_id: Optional[str]): def set_id_of_node(self, se: SyncNode, node_id: Optional[str]):
"""sets the ID attribute of the given SyncNode. If node_id is None, a negative Id will be """sets the ID attribute of the given SyncNode. If node_id is None, a negative Id will be
...@@ -407,37 +407,35 @@ class SyncGraph(): ...@@ -407,37 +407,35 @@ class SyncGraph():
def _mark_entities_with_path_or_id(self): def _mark_entities_with_path_or_id(self):
""" A path or an ID is sufficiently identifying. Thus, those entities can be marked as """ A path or an ID is sufficiently identifying. Thus, those entities can be marked as
checked """ checked """
for semantic_entity in list(self.nodes[::-1]): for node in list(self.nodes[::-1]):
assert len(semantic_entity.fragments) == 1 if node.id is None and node.path is None:
entity = semantic_entity.fragments[0]
if entity.id is None and entity.path is None:
continue continue
if entity.path is not None: if node.path is not None:
try: try:
existing = cached_get_entity_by(path=entity.path) existing = cached_get_entity_by(path=node.path)
except EmptyUniqueQueryError: except EmptyUniqueQueryError:
existing = None existing = None
if existing is not None: if existing is not None:
semantic_entity.identify_with(existing) node.identify_with(existing)
# at this point, semantic_entity has an ID if it is existing # at this point, node has an ID if it is existing
treated_before = self.get_equivalent(semantic_entity) treated_before = self.get_equivalent(node)
if treated_before is None: if treated_before is None:
if semantic_entity.id is None or semantic_entity.id < 0: if node.id is None or node.id < 0:
self.set_missing(semantic_entity) self.set_missing(node)
else: else:
self.set_existing(semantic_entity) self.set_existing(node)
else: else:
self._merge_into(semantic_entity, treated_before) self._merge_into(node, treated_before)
def _remove_non_identifiables(self): def _remove_non_identifiables(self):
""" A path or an ID is sufficiently identifying. Thus, those entities can be marked as """ A path or an ID is sufficiently identifying. Thus, those entities can be marked as
checked """ checked """
for semantic_entity in list(self.nodes[::-1]): for node in list(self.nodes[::-1]):
if "nonidentifiable" in [p.name for p in if "nonidentifiable" in [p.name for p in
semantic_entity.registered_identifiable.properties]: node.registered_identifiable.properties]:
self.unchecked.remove(semantic_entity) self.unchecked.remove(node)
def _add_any(self, entity: SyncNode, lookup): def _add_any(self, entity: SyncNode, lookup):
"""Add ``entity`` to this SemanticTarget and store in ``lookup`` cache. """Add ``entity`` to this SemanticTarget and store in ``lookup`` cache.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment