MetadatumLabelList
- class cometa.auxiliary_data.metadatum_label_list.MetadatumLabelList(ptr=None)[source]
Bases:
Sequence[int]Represents a list of metadatum labels (unsigned 64-bit integers).
Labels are used to identify metadata entries in transactions. Common labels include 721 for NFTs (CIP-25).
Example
>>> label_list = MetadatumLabelList() >>> label_list.add(721) >>> label_list.add(674) >>> len(label_list) 2
- classmethod from_list(labels)[source]
Creates a MetadatumLabelList from an iterable of integers.
- Parameters:
labels (Iterable[int]) – An iterable of metadata labels (unsigned 64-bit integers).
- Returns:
A new MetadatumLabelList containing all the labels.
- Raises:
CardanoError – If creation fails.
- Return type:
- add(label)[source]
Adds a label to the list.
- Parameters:
label (int) – The metadata label (unsigned 64-bit integer).
- Raises:
CardanoError – If the operation fails.
- Return type:
None
- get(index)[source]
Retrieves a label by index.
- Parameters:
index (int) – The index of the element to retrieve.
- Returns:
The label at the specified index.
- Raises:
CardanoError – If retrieval fails.
IndexError – If index is out of bounds.
- Return type:
int
- __getitem__(index)[source]
Gets a label by index using bracket notation. Supports negative indices.
- Parameters:
index (int)
- Return type:
int
- __contains__(item)[source]
Checks if a label is in the list.
- Parameters:
item (int)
- Return type:
bool
- append(label)[source]
Appends a label to the list.
This is an alias for add() to match Python list semantics.
- Parameters:
label (int) – The metadata label to append.
- Return type:
None
- index(value, start=0, stop=None)[source]
Returns the index of the first occurrence of value.
- Parameters:
value (int) – The value to search for.
start (int) – Start searching from this index.
stop (int | None) – Stop searching at this index.
- Returns:
The index of the first occurrence.
- Raises:
ValueError – If the value is not found.
- Return type:
int