election_ids

exception uk_election_timetables.election_ids.AmbiguousElectionIdError(election_id: str)

Bases: BaseException

An exception type to represent when an election id (usually a group such as local.2019-05-02) can correspond to elections in multiple countries with different legislation governing the publish date of Statements of Persons Nominated.

exception uk_election_timetables.election_ids.InvalidElectionIdError(election_id: str)

Bases: BaseException

An exception type to represent when an election id does not confirm to DemocracyClub’s uk-election-ids format

exception uk_election_timetables.election_ids.NoSuchElectionTypeError(election_type: str)

Bases: BaseException

An exception type to represent when an election type doesn’t actually represent a valid election.

uk_election_timetables.election_ids.from_election_id(election_id: str, country: Optional[Country] = None) Election

Calculate the publish date for an election given in uk-election-ids format and an optional country if necessary (for example, local or parliamentary elections).

Parameters:
  • election_id – a string representing an election id in uk-election-ids format

  • country – an optional Country representing the country where the election will be held

Returns:

a datetime representing the expected publish date

uk_election_timetables.election_ids.type_and_poll_date(election_id: str) -> (<class 'str'>, <class 'datetime.date'>)

Extract election_type (e.g. parl, local, mayor) and poll_date from an election id.

Parameters:

election_id

a string representing an election id in uk-election-ids format

Returns:

a tuple (election_type: str, poll_date: date)