VotingProcedureList

class cometa.voting_procedures.voting_procedure_list.VotingProcedureList(ptr=None)[source]

Bases: Sequence[VotingProcedure]

Represents a list of Voting Procedures.

This class provides a collection interface for managing multiple VotingProcedures, supporting standard list operations like iteration, indexing, and slicing.

Example

>>> from cometa import VotingProcedureList, VotingProcedure
>>> procedure_list = VotingProcedureList()
>>> procedure_list.add(procedure)
>>> print(len(procedure_list))
1
__init__(ptr=None)[source]
Return type:

None

__enter__()[source]
Return type:

VotingProcedureList

__exit__(exc_type, exc_val, exc_tb)[source]
Return type:

None

__repr__()[source]

Return repr(self).

Return type:

str

__len__()[source]

Returns the number of voting procedures in the list.

Return type:

int

__iter__()[source]

Iterates over all voting procedures in the list.

Return type:

Iterator[VotingProcedure]

__getitem__(index)[source]

Gets a voting procedure by index using bracket notation.

Parameters:

index (int)

Return type:

VotingProcedure

__bool__()[source]

Returns True if the list is not empty.

Return type:

bool

classmethod from_list(procedures)[source]

Creates a VotingProcedureList from a Python list of VotingProcedure objects.

Parameters:

procedures (list[VotingProcedure]) – A list of VotingProcedure objects.

Returns:

A new VotingProcedureList containing all the voting procedures.

Raises:

CardanoError – If creation fails.

Return type:

VotingProcedureList

Example

>>> procedure_list = VotingProcedureList.from_list([procedure1, procedure2, procedure3])
add(procedure)[source]

Adds a voting procedure to the end of the list.

Parameters:

procedure (VotingProcedure) – The VotingProcedure to add.

Raises:

CardanoError – If addition fails.

Return type:

None

get(index)[source]

Retrieves a voting procedure at the specified index.

Parameters:

index (int) – The index of the voting procedure to retrieve.

Returns:

The VotingProcedure at the specified index.

Raises:
  • CardanoError – If retrieval fails.

  • IndexError – If index is out of bounds.

Return type:

VotingProcedure

append(procedure)[source]

Appends a voting procedure to the end of the list (alias for add).

Parameters:

procedure (VotingProcedure) – The VotingProcedure 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 (VotingProcedure) – 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 (VotingProcedure) – The value to count.

Returns:

The number of occurrences.

Return type:

int