swissvotes.models.column_mapper

Module Contents

Classes

ColumnMapperDataset

Defines the columns used in the dataset and provides helper functions.

ColumnMapperMetadata

Defines the columns used for the metadata and provides helper

Attributes

ColumnItem

swissvotes.models.column_mapper.ColumnItem: typing_extensions.TypeAlias[source]
class swissvotes.models.column_mapper.ColumnMapperDataset[source]

Defines the columns used in the dataset and provides helper functions.

Typically, you want to iterate over all attributes of a vote (columns, items, get_values, get_items) and set/get them (set_value, get_value).

columns() dict[str, str][source]

The SwissVote attribute name and its column in the dataset.

Attribute names starting with an ! are used to indicate JSON attributes.

set_value(vote: onegov.swissvotes.models.vote.SwissVote, attribute: str, value: Any) None[source]

Set the given value of a vote.

get_value(vote: onegov.swissvotes.models.vote.SwissVote, attribute: str) Any[source]

Get the given value of a vote.

get_values(vote: onegov.swissvotes.models.vote.SwissVote) Iterator[Any][source]

Get all values of a vote in order.

get_items(vote: onegov.swissvotes.models.vote.SwissVote) Iterator[tuple[str, Any]][source]

Get all names and values of a vote in order.

items() Iterator[ColumnItem][source]

Returns the attributes and column names together with additional information (type, nullable, precision, scale).

class swissvotes.models.column_mapper.ColumnMapperMetadata[source]

Defines the columns used for the metadata and provides helper functions.

Typically, you want to iterate over all attributes of a vote (columns, items, get_values, get_items) and set/get them (set_value, get_value).

columns() dict[str, str][source]

The SwissVote attribute name and its column in the metadata file.

Each line contains a type hint, a nullable hint, an attribute and optionally a key for list items.

set_value(data: dict[str, Any], attribute: str, value: Any) None[source]

Set the given value to the metadata dict of a single line.

items() Iterator[ColumnItem][source]

Returns the attributes and column names together with additional information (type, nullable, precision, scale).