Skip to content
Snippets Groups Projects
Verified Commit 428fe969 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

MAINT: Removing unused functions, documentation, fixmes.

parent f7f89bc6
No related branches found
No related tags found
2 merge requests!178FIX: #96 Better error output for crawl.py script.,!167Sync Graph
Pipeline #50008 passed with warnings
...@@ -97,8 +97,7 @@ class SemanticTarget(): ...@@ -97,8 +97,7 @@ class SemanticTarget():
are updated according to the reference map. are updated according to the reference map.
This model should only be manipulated via three functions: This model should only be manipulated via three functions:
- make_identifiable: adds an identifiable to a SemanticEntity what possibly allows to merge it - make_identifiable: adds an identifiable to a SemanticEntity
with another SemanticEntity
- merge_with_equivalent: check whether there is an equivalent SemanticEntity and merge into - merge_with_equivalent: check whether there is an equivalent SemanticEntity and merge into
that if one is found that if one is found
- check_remote_server: uses the identifiable to check the remote server and add ID and path if - check_remote_server: uses the identifiable to check the remote server and add ID and path if
...@@ -143,15 +142,14 @@ class SemanticTarget(): ...@@ -143,15 +142,14 @@ class SemanticTarget():
self._mark_entities_with_path_or_id() self._mark_entities_with_path_or_id()
def make_identifiable(self, se: SemanticEntity): def make_identifiable(self, se: SemanticEntity):
""" creates an identifiable for the given SemanticEntity and possibly merges it into an """Create an identifiable for the given SemanticEntity and store it there.
equivalent SemanticEntity
""" """
if se.identifiable is not None: if se.identifiable is not None:
raise RuntimeError("Already has identifiable") raise RuntimeError("Already has identifiable")
se.identifiable = self.identifiableAdapter.get_identifiable( se.identifiable = self.identifiableAdapter.get_identifiable(
se, self.backward_id_referenced_by[se.uuid]) se, self.backward_id_referenced_by[se.uuid])
def merge_with_equivalent(self, se: SemanticEntity): def merge_with_equivalent(self, se: SemanticEntity) -> bool:
equivalent_se = self.get_checked_equivalent(se) equivalent_se = self.get_checked_equivalent(se)
if equivalent_se is None: if equivalent_se is None:
return False return False
...@@ -159,14 +157,14 @@ class SemanticTarget(): ...@@ -159,14 +157,14 @@ class SemanticTarget():
self._merge_into(se, equivalent_se) self._merge_into(se, equivalent_se)
return True return True
def check_remote_server(self, se: SemanticEntity): def check_remote_server(self, se: SemanticEntity) -> None:
identified_record = ( identified_record = (
self.identifiableAdapter.retrieve_identified_record_for_identifiable( self.identifiableAdapter.retrieve_identified_record_for_identifiable(
se.identifiable)) se.identifiable))
if identified_record is not None: if identified_record is not None:
se.identify_with(identified_record) se.identify_with(identified_record)
def set_missing(self, se: SemanticEntity): def set_missing(self, se: SemanticEntity) -> None:
""" add the given SemanticEntity to the list of missing entities """ add the given SemanticEntity to the list of missing entities
This removes the SemanticEntity from the unchecked list and implies that the entity does This removes the SemanticEntity from the unchecked list and implies that the entity does
...@@ -208,27 +206,27 @@ class SemanticTarget(): ...@@ -208,27 +206,27 @@ class SemanticTarget():
self._identifiable_look_up): self._identifiable_look_up):
return self._identifiable_look_up[entity.identifiable.get_representation()] return self._identifiable_look_up[entity.identifiable.get_representation()]
def get_equivalent_existing(self, se): # def get_equivalent_existing(self, se):
""" Check whether this Record exists on the remote server # """ Check whether this Record exists on the remote server
Returns: The stored Record # Returns: The stored Record
""" # """
treated = self.get_any(se) # treated = self.get_any(se)
if id(treated) in self._existing: # if id(treated) in self._existing:
return rec # return rec
else: # else:
return None # return None
def get_equivalent_missing(self, se): # def get_equivalent_missing(self, se):
""" Check whether this Record is missing on the remote server # """ Check whether this Record is missing on the remote server
Returns: The stored Record # Returns: The stored Record
""" # """
treated = self.get_any(record, identifiable) # treated = self.get_any(record, identifiable)
if id(treated) in self._missing: # if id(treated) in self._missing:
return rec # return rec
else: # else:
return None # return None
def combine_fragments(self): def combine_fragments(self):
for se in self.se: for se in self.se:
...@@ -473,13 +471,19 @@ class SemanticTarget(): ...@@ -473,13 +471,19 @@ class SemanticTarget():
if referenced in self.unchecked: if referenced in self.unchecked:
if referenced in circle: if referenced in circle:
closed = True closed = True
circle.append(pval) circle.append(pval) # FIXME
added_to_circle = True added_to_circle = True
if not added_to_circle: if not added_to_circle:
return None return None
return circle return circle
def _add_any(self, entity: SemanticEntity, lookup): def _add_any(self, entity: SemanticEntity, lookup):
"""Add ``entity`` to this SemanticTarget and store in ``lookup`` cache.
The entity is stored in the SemanticEntity's ``id``, ``path`` and ``identifiable`` lookup tables, if
the respective attributes exist.
"""
if entity.id is not None: if entity.id is not None:
self._id_look_up[entity.id] = entity self._id_look_up[entity.id] = entity
if entity.path is not None: if entity.path is not None:
...@@ -489,7 +493,7 @@ class SemanticTarget(): ...@@ -489,7 +493,7 @@ class SemanticTarget():
lookup[id(entity)] = entity lookup[id(entity)] = entity
def _merge_into(self, source: SemanticEntity, target: SemanticEntity): def _merge_into(self, source: SemanticEntity, target: SemanticEntity):
""" tries to merge record into newrecord """ FIXME tries to merge record into newrecord
If it fails, record is added to the try_to_merge_later list. If it fails, record is added to the try_to_merge_later list.
In any case, references are bent to the newrecord object. In any case, references are bent to the newrecord object.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment