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: Optional[RecordType] = 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.

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.

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: _Properties) bool

helper function that checks whether a property with the same name or ID is in the plist