IdMap
- class IdMap
DeserializedModelcompatible mapping for elements. This will typically be used for linking pending references:map = IdMap() models_reports = [ deserializer.accept(document, my_reader(input), DESERIALIZE_STANDARD) for document, input in zip(documents, inputs) ] for document in documents: map.insert_or_assign(document) reports_linked = [model.link(map) for model, _ in models_reports]
Members defined in
IdMap(8 members)
Methods
- __call__(uri: str, id: uuid.UUID) syside.Element | None
Short-hand for
find.
- __init__() None
- clear() None
Clear all mapped elements.
- erase(document: syside.Document) int
Erase all elements assigned to
documentfrom this map.Returns the number of elements erased.
- erase(uri: str) int
Erase all elements assigned to document with
urifrom this map.Returns the number of elements erased.
- find(uri: str, id: uuid.UUID) syside.Element | None
Find an element at document with
urithat hasid.Returns the element found if any.
- insert_or_assign(document: syside.Document) tuple[int, bool]
Insert all elements from
documentinto this map.Returns the number of elements inserted, and
Trueif insertion took place,Falseifdocumentwas already mapped.
- reserve(n: int) None
Reserve space for
ndocument mappings.
- try_insert(document: syside.Document) tuple[int, bool]
Try insert all elements from
documentinto this map.Returns the number of elements inserted, and
Trueif insertion took place. This will not override already mapped document elements.