caoscrawler.sync_node module
- class caoscrawler.sync_node.TempID
Bases:
int
A special kind of int for negative temporary IDs.
This allows to identify TempIDs in the presence of String IDs. A string ID might look like a negative integer.
- class caoscrawler.sync_node.SyncNode(entity: Entity, registered_identifiable: RecordType | None = None, **kwargs)
Bases:
Entity
represents the information of an Entity as it shall be created in LinkAhead
The following information is taken from an db.Entity object during initialization or when the object is updated using the update member function: - id - role - path - file - name - description - parents - properties
Typically, this class is used in the following way: 1. A SyncNode is initialized with a db.Entity object. 2. The SyncNode object is possibly updated one or more times with other SyncNode objects. 3. A db.Entity object is created (export_entity) that contains the combined information.
- update(other: SyncNode) None
Update this node with information of given
other
SyncNode.parents are added if they are not yet in the list properties are added in any case. This may lead to duplication of properties. We allow this duplication here and remove it when we create a db.Entity (export_entity function) because if property values are SyncNode objects, they might not be comparable (no ID, no identifiable) yet.
- Raises:
ValueError: – The other SyncNode doesn’t share identifiables with this SyncNode, so they can’t be merged.
ImpossibleMergeError: – The two SyncNodes are incompatible in their attributes like “id”, “role”, “path”, “file”, “name”, or “description”.
- export_entity() Entity
create a db.Entity object from this SyncNode
Properties are only added once (based on id or name). If values do not match, an Error is raised. If values are SyncNode objects with IDs, they are considered equal if their IDs are equal.
- Raises:
RuntimeError: – In case of a unsupported role, so no Entity can’t be created.
ImpossibleMergeError: – In case of conflicting property values in this SyncNode.
- caoscrawler.sync_node.parent_in_list(parent: Parent, plist: ParentList) bool
helper function that checks whether a parent with the same name or ID is in the plist
- caoscrawler.sync_node.property_in_list(prop: Property, plist: PropertyList) bool
helper function that checks whether a property with the same name or ID is in the plist