election_day.formats.imports.election.internal_proporz

Attributes

INTERNAL_PROPORZ_HEADERS

Functions

parse_election(→ Status | None)

parse_election_result(→ dict[str, Any] | bool)

parse_list(→ dict[str, Any] | None)

parse_list_result(→ dict[str, Any] | None)

parse_list_panachage_headers(→ dict[str, str])

parse_list_panachage_results(→ None)

parse_candidate(→ dict[str, Any] | None)

parse_candidate_result(→ dict[str, Any] | None)

parse_candidate_panachage_headers(→ dict[str, str])

parse_candidate_panachage_results(→ None)

prefix_connection_id(→ str)

Used to distinguish connection ids when they have the same id

parse_connection(→ tuple[dict[str, Any] | None, ...)

import_election_internal_proporz(...)

Tries to import the given file (internal format).

Module Contents

election_day.formats.imports.election.internal_proporz.INTERNAL_PROPORZ_HEADERS = ('election_status', 'entity_id', 'entity_counted', 'entity_eligible_voters',...[source]
election_day.formats.imports.election.internal_proporz.parse_election(line: onegov.core.csv.DefaultRow, errors: list[str]) Status | None[source]
election_day.formats.imports.election.internal_proporz.parse_election_result(line: onegov.core.csv.DefaultRow, errors: list[str], entities: dict[int, dict[str, str]], election: onegov.election_day.models.Election, principal: Canton | Municipality, ignore_extra: bool) dict[str, Any] | bool[source]
election_day.formats.imports.election.internal_proporz.parse_list(line: onegov.core.csv.DefaultRow, errors: list[str], election_id: str, colors: dict[str, str]) dict[str, Any] | None[source]
election_day.formats.imports.election.internal_proporz.parse_list_result(line: onegov.core.csv.DefaultRow, errors: list[str], counted: bool) dict[str, Any] | None[source]
election_day.formats.imports.election.internal_proporz.parse_list_panachage_headers(csv: onegov.core.csv.DefaultCSVFile) dict[str, str][source]
election_day.formats.imports.election.internal_proporz.parse_list_panachage_results(line: onegov.core.csv.DefaultRow, errors: list[str], values: dict[str, dict[str, int]], headers: dict[str, str]) None[source]
election_day.formats.imports.election.internal_proporz.parse_candidate(line: onegov.core.csv.DefaultRow, errors: list[str], election_id: str, colors: dict[str, str]) dict[str, Any] | None[source]
election_day.formats.imports.election.internal_proporz.parse_candidate_result(line: onegov.core.csv.DefaultRow, errors: list[str], counted: bool) dict[str, Any] | None[source]
election_day.formats.imports.election.internal_proporz.parse_candidate_panachage_headers(csv: onegov.core.csv.DefaultCSVFile) dict[str, str][source]
election_day.formats.imports.election.internal_proporz.parse_candidate_panachage_results(line: onegov.core.csv.DefaultRow, errors: list[str], values: list[dict[str, Any]], headers: dict[str, str]) None[source]
election_day.formats.imports.election.internal_proporz.prefix_connection_id(connection_id: str, parent_connection_id: str) str[source]

Used to distinguish connection ids when they have the same id as a parent_connection.

election_day.formats.imports.election.internal_proporz.parse_connection(line: onegov.core.csv.DefaultRow, errors: list[str], election_id: str) tuple[dict[str, Any] | None, dict[str, Any] | None][source]
election_day.formats.imports.election.internal_proporz.import_election_internal_proporz(election: onegov.election_day.models.Election, principal: Canton | Municipality, file: IO[bytes], mimetype: str, ignore_extra: bool = False) list[onegov.election_day.formats.imports.common.FileImportError][source]

Tries to import the given file (internal format).

This function is typically called automatically every few minutes during an election day - we use bulk inserts to speed up the import.

Optionally ignores results not being part of this election.

Returns:

A list containing errors.