Skip to content
Snippets Groups Projects
Commit ba7dc1e1 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

DOC: added a few source code comments to the sync graph

parent 5384dcdc
No related branches found
No related tags found
2 merge requests!178FIX: #96 Better error output for crawl.py script.,!167Sync Graph
Pipeline #51237 failed
...@@ -62,6 +62,8 @@ def _for_each_scalar_value(node: SyncNode, condition: Callable[[Any], bool], kin ...@@ -62,6 +62,8 @@ def _for_each_scalar_value(node: SyncNode, condition: Callable[[Any], bool], kin
it returns True for the property value, the action is executed. it returns True for the property value, the action is executed.
kind (str): Either "remove" or "set" depending on whether you want to remove the property or replace the property. kind (str): Either "remove" or "set" depending on whether you want to remove the property or replace the property.
value (Callable): A function returning a new value that is set as the property value. This function receives the old value as the single argument. value (Callable): A function returning a new value that is set as the property value. This function receives the old value as the single argument.
Last review by Alexander Schlemmer on 2024-05-24.
""" """
for p in node.properties: for p in node.properties:
if isinstance(p.value, list): if isinstance(p.value, list):
...@@ -122,7 +124,7 @@ class SyncGraph(): ...@@ -122,7 +124,7 @@ class SyncGraph():
Usage: Usage:
- Initialize the Graph with a list of entities. Those will be converted to the SyncNodes of the - Initialize the Graph with a list of entities. Those will be converted to the SyncNodes of the
graph. graph.
- SyncNodes that can be merged are automatically merged and SyncNodes where the existance can - SyncNodes that can be merged are automatically merged and SyncNodes where the existence can
be determined are automatically removed from the list of unchecked SyncNodes: be determined are automatically removed from the list of unchecked SyncNodes:
graph.unchecked. graph.unchecked.
- You manipulate the graph by setting the ID of a SyncNode (either to a valid ID or to None). - You manipulate the graph by setting the ID of a SyncNode (either to a valid ID or to None).
...@@ -132,6 +134,8 @@ class SyncGraph(): ...@@ -132,6 +134,8 @@ class SyncGraph():
- Ideally, the unchecked list is empty after some manipulation. - Ideally, the unchecked list is empty after some manipulation.
- You can export a list of entities to be inserted and one of entities to be updated with - You can export a list of entities to be inserted and one of entities to be updated with
export_record_lists. export_record_lists.
Last review by Alexander Schlemmer on 2024-05-24.
""" """
def __init__(self, entities: list[db.Entity], identifiableAdapter: IdentifiableAdapter): def __init__(self, entities: list[db.Entity], identifiableAdapter: IdentifiableAdapter):
...@@ -168,8 +172,9 @@ class SyncGraph(): ...@@ -168,8 +172,9 @@ class SyncGraph():
if self._identifiable_is_needed(node): if self._identifiable_is_needed(node):
self._set_identifiable_of_node(node) self._set_identifiable_of_node(node)
# everything in unchecked has no ID nor path. Thus, it must be possible to create an # everything in unchecked neither das have an ID nor a path.
# identifiable. # Thus, it must be possible to create an
# identifiable which is checked using the following function:
for node in self.unchecked: for node in self.unchecked:
self.identifiableAdapter.check_identifying_props(node) self.identifiableAdapter.check_identifying_props(node)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment