GovernanceActionIdList
- class cometa.voting_procedures.governance_action_id_list.GovernanceActionIdList(ptr=None)[source]
Bases:
Sequence[GovernanceActionId]Represents a list of Governance Action IDs.
This class provides a collection interface for managing multiple GovernanceActionIds, supporting standard list operations like iteration, indexing, and slicing.
Example
>>> from cometa import GovernanceActionIdList, GovernanceActionId >>> action_id_list = GovernanceActionIdList() >>> action_id_list.add(action_id) >>> print(len(action_id_list)) 1
- __iter__()[source]
Iterates over all governance action IDs in the list.
- Return type:
Iterator[GovernanceActionId]
- __getitem__(index)[source]
Gets a governance action ID by index using bracket notation.
- Parameters:
index (int)
- Return type:
- __bool__()[source]
Returns True if the list is not empty.
- Returns:
True if the list contains at least one element, False otherwise.
- Return type:
bool
- classmethod from_list(action_ids)[source]
Creates a GovernanceActionIdList from a Python list of GovernanceActionId objects.
- Parameters:
action_ids (list[GovernanceActionId]) – A list of GovernanceActionId objects.
- Returns:
A new GovernanceActionIdList containing all the governance action IDs.
- Raises:
CardanoError – If creation fails.
- Return type:
Example
>>> action_id_list = GovernanceActionIdList.from_list([action_id1, action_id2, action_id3])
- add(action_id)[source]
Adds a governance action ID to the end of the list.
- Parameters:
action_id (GovernanceActionId) – The GovernanceActionId to add.
- Raises:
CardanoError – If addition fails.
- Return type:
None
- get(index)[source]
Retrieves a governance action ID at the specified index.
- Parameters:
index (int) – The index of the governance action ID to retrieve.
- Returns:
The GovernanceActionId at the specified index.
- Raises:
CardanoError – If retrieval fails.
IndexError – If index is out of bounds.
- Return type:
- append(action_id)[source]
Appends a governance action ID to the end of the list (alias for add).
- Parameters:
action_id (GovernanceActionId) – The GovernanceActionId to append.
- Raises:
CardanoError – If appending fails.
- Return type:
None
- index(value, start=0, stop=None)[source]
Returns the index of the first occurrence of value.
- Parameters:
value (GovernanceActionId) – 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
- count(value)[source]
Returns the number of occurrences of value.
- Parameters:
value (GovernanceActionId) – The value to count.
- Returns:
The number of occurrences.
- Return type:
int