election_day.formats.imports.election.internal_proporz

Attributes

INTERNAL_PROPORZ_HEADERS

Functions

parse_election(line, errors) → onegov.election_day.types.Status | None

parse_election_result(line, errors, entities, ...) → dict[str, Any] | bool

parse_list(line, errors, election_id, colors) → dict[str, Any] | None

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

parse_list_panachage_headers(csv) → dict[str, str]

parse_list_panachage_results(line, errors, values, headers) → None

parse_candidate(line, errors, election_id, colors) → dict[str, Any] | None

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

parse_candidate_panachage_headers(csv) → dict[str, str]

parse_candidate_panachage_results(line, errors, ...) → None

prefix_connection_id(connection_id, parent_connection_id) → str

Used to distinguish connection ids when they have the same id

parse_connection(line, errors, election_id) → tuple[dict[str, Any] | None, dict[str, Any] | None]

import_election_internal_proporz(election, principal, ...) → list[onegov.election_day.formats.imports.common.FileImportError]

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]) → onegov.election_day.types.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: onegov.election_day.models.Canton | onegov.election_day.models.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: onegov.election_day.models.Canton | onegov.election_day.models.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.