syside.IdMap

class IdMap

DeserializedModel compatible 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]

Initialization

insert_or_assign(document: syside.Document) tuple[int, bool]

Insert all elements from document into this map.

Returns the number of elements inserted, and True if insertion took place, False if document was already mapped.

try_insert(document: syside.Document) tuple[int, bool]

Try insert all elements from document into this map.

Returns the number of elements inserted, and True if insertion took place. This will not override already mapped document elements.

erase(document: syside.Document) int

Erase all elements assigned to document from this map.

Returns the number of elements erased.

erase(uri: str) int

Erase all elements assigned to document with uri from this map.

Returns the number of elements erased.

clear() None

Clear all mapped elements.

reserve(n: int) None

Reserve space for n document mappings.

find(uri: str, id: uuid.UUID) syside.Element | None

Find an element at document with uri that has id.

Returns the element found if any.

__call__(uri: str, id: uuid.UUID) syside.Element | None

Short-hand for find.