medkit.core.attribute_container#

Classes#

AttributeContainer

Manage a list of attributes attached to another data structure.

Module Contents#

class medkit.core.attribute_container.AttributeContainer(owner_id: str)#

Manage a list of attributes attached to another data structure.

For example, it may be a document or an annotation.

This behaves more or less like a list: calling len() and iterating are supported. Additional filtering is available through the get() method.

The attributes will be stored in a Store, which can rely on a simple dict or something more complicated like a database.

This global store may be initialized using :class:~medkit.core.GlobalStore. Otherwise, a default one (i.e. dict store) is used.

_store: medkit.core.store.Store#
_owner_id#
_attr_ids: list[str] = []#
_attr_ids_by_label: dict[str, list[str]]#
__len__() int#

Add support for calling len().

__iter__() Iterator[medkit.core.attribute.Attribute]#

Add support for iterating over each attribute.

__getitem__(key: int | slice) medkit.core.attribute.Attribute | list[medkit.core.attribute.Attribute]#

Add support for subscript access.

get(*, label: str | None = None) list[medkit.core.attribute.Attribute]#

Return a list of the attributes of the annotation.

Parameters:
labelstr, optional

Label to use to filter attributes.

Returns:
list of Attribute

The list of all attributes of the annotation, filtered by label if specified.

add(attr: medkit.core.attribute.Attribute)#

Attach an attribute to the annotation.

Parameters:
attrAttribute

Attribute to add.

Raises:
ValueError

If the attribute is already attached to the annotation (based on attr.uid).

get_by_id(uid: str) medkit.core.attribute.Attribute#

Return the attribute corresponding to a specific identifier.

Parameters:
uidstr

Identifier of the attribute to return.

Returns:
Attribute

The attribute corresponding to the identifier

__eq__(other: object) bool#
__repr__() str#