from functools import cached_property
from collections import OrderedDict
from onegov.swissvotes.models.vote import SwissVote
from typing import Any
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Iterator
from typing import TypeAlias
[docs]
ColumnItem: TypeAlias = tuple[
str, # attribute
str, # column
str | None, # type
bool, # nullable
int | None, # precision
int | None # scale
]
[docs]
class ColumnMapperDataset:
""" 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``).
"""
@cached_property
[docs]
def columns(self) -> dict[str, str]:
""" The SwissVote attribute name and its column in the dataset.
Attribute names starting with an ``!`` are used to indicate JSON
attributes.
"""
return OrderedDict((
('bfs_number', 'anr'),
('date', 'datum'),
('short_title_de', 'titel_kurz_d'),
('short_title_fr', 'titel_kurz_f'),
('short_title_en', 'titel_kurz_e'),
('title_de', 'titel_off_d'),
('title_fr', 'titel_off_f'),
('keyword', 'stichwort'),
('_legal_form', 'rechtsform'),
('anneepolitique', 'anneepolitique'),
('!t!content!link_bk_chrono_de', 'bkchrono-de'),
('!t!content!link_bk_chrono_fr', 'bkchrono-fr'),
('descriptor_1_level_1', 'd1e1'),
('descriptor_1_level_2', 'd1e2'),
('descriptor_1_level_3', 'd1e3'),
('descriptor_2_level_1', 'd2e1'),
('descriptor_2_level_2', 'd2e2'),
('descriptor_2_level_3', 'd2e3'),
('descriptor_3_level_1', 'd3e1'),
('descriptor_3_level_2', 'd3e2'),
('descriptor_3_level_3', 'd3e3'),
('_position_federal_council', 'br-pos'),
('!t!content!link_curia_vista_de', 'curiavista-de'),
('!t!content!link_curia_vista_fr', 'curiavista-fr'),
('_position_parliament', 'bv-pos'),
('_position_national_council', 'nr-pos'),
('position_national_council_yeas', 'nrja'),
('position_national_council_nays', 'nrnein'),
('_position_council_of_states', 'sr-pos'),
('position_council_of_states_yeas', 'srja'),
('position_council_of_states_nays', 'srnein'),
('duration_federal_assembly', 'dauer_bv'),
('duration_initative_collection', 'i-dauer_samm'),
('duration_referendum_collection', 'fr-dauer_samm'),
('signatures_valid', 'unter_g'),
('_parliamentary_initiated', 'pa-iv'),
('initiator_de', 'urheber'),
('initiator_fr', 'urheber-fr'),
('!i!recommendations!fdp', 'p-fdp'),
('!i!recommendations!cvp', 'p-cvp'),
('!i!recommendations!sps', 'p-sps'),
('!i!recommendations!svp', 'p-svp'),
('!i!recommendations!evp', 'p-evp'),
('!i!recommendations!csp', 'p-ucsp'),
('!i!recommendations!pda', 'p-pda'),
('!i!recommendations!gps', 'p-gps'),
('!i!recommendations!sd', 'p-sd'),
('!i!recommendations!edu', 'p-edu'),
('!i!recommendations!fps', 'p-fps'),
('!i!recommendations!lega', 'p-lega'),
('!i!recommendations!kvp', 'p-kvp'),
('!i!recommendations!glp', 'p-glp'),
('!i!recommendations!bdp', 'p-bdp'),
('!i!recommendations!mcg', 'p-mcg'),
('!i!recommendations!lps', 'p-lps'),
('!i!recommendations!ldu', 'p-ldu'),
('!i!recommendations!poch', 'p-poch'),
('!i!recommendations!rep', 'p-rep'),
('!i!recommendations!mitte', 'p-mitte'),
('!i!recommendations!sav', 'p-sav'),
('!i!recommendations!eco', 'p-eco'),
('!i!recommendations!sgv', 'p-sgv'),
('!i!recommendations!sbv-usp', 'p-sbv'),
('!i!recommendations!sgb', 'p-sgb'),
('!i!recommendations!travs', 'p-travs'),
('!i!recommendations!vsa', 'p-vsa'),
('!i!recommendations!vpod', 'p-vpod'),
('!i!recommendations!voev', 'p-voev'),
('!i!recommendations!tcs', 'p-tcs'),
('!i!recommendations!vcs', 'p-vcs'),
('!i!recommendations!acs', 'p-acs'),
('!i!recommendations!sbk', 'p-sbk'),
('!i!recommendations!ssv', 'p-ssv'),
('!i!recommendations!gem', 'p-gem'),
('!i!recommendations!kdk', 'p-kdk'),
('!i!recommendations!kkjpd', 'p-kkjpd'),
('!i!recommendations!gdk', 'p-gdk'),
('!i!recommendations!ldk', 'p-ldk'),
('!i!recommendations!vdk', 'p-vdk'),
('!i!recommendations!sodk', 'p-sodk'),
('!i!recommendations!endk', 'p-endk'),
('!i!recommendations!fdk', 'p-fdk'),
('!i!recommendations!edk', 'p-edk'),
('!i!recommendations!bpuk', 'p-bpuk'),
('recommendations_other_yes_de', 'p-others_yes'),
('recommendations_other_yes_fr', 'p-others_yes-fr'),
('recommendations_other_no_de', 'p-others_no'),
('recommendations_other_no_fr', 'p-others_no-fr'),
('recommendations_other_free_de', 'p-others_free'),
('recommendations_other_free_fr', 'p-others_free-fr'),
('recommendations_other_counter_proposal_de', 'p-others_counterp'),
('recommendations_other_counter_proposal_fr',
'p-others_counterp-fr'),
('recommendations_other_popular_initiative_de', 'p-others_init'),
('recommendations_other_popular_initiative_fr',
'p-others_init-fr'),
('!i!recommendations_divergent!bdp_ag', 'pdev-bdp_AG'),
('!i!recommendations_divergent!bdp_ai', 'pdev-bdp_AI'),
('!i!recommendations_divergent!bdp_ar', 'pdev-bdp_AR'),
('!i!recommendations_divergent!bdp_be', 'pdev-bdp_BE'),
('!i!recommendations_divergent!bdp_bl', 'pdev-bdp_BL'),
('!i!recommendations_divergent!bdp_bs', 'pdev-bdp_BS'),
('!i!recommendations_divergent!bdp_fr', 'pdev-bdp_FR'),
('!i!recommendations_divergent!bdp_ge', 'pdev-bdp_GE'),
('!i!recommendations_divergent!bdp_gl', 'pdev-bdp_GL'),
('!i!recommendations_divergent!bdp_gr', 'pdev-bdp_GR'),
('!i!recommendations_divergent!bdp_ju', 'pdev-bdp_JU'),
('!i!recommendations_divergent!bdp_lu', 'pdev-bdp_LU'),
('!i!recommendations_divergent!bdp_ne', 'pdev-bdp_NE'),
('!i!recommendations_divergent!bdp_nw', 'pdev-bdp_NW'),
('!i!recommendations_divergent!bdp_ow', 'pdev-bdp_OW'),
('!i!recommendations_divergent!bdp_sg', 'pdev-bdp_SG'),
('!i!recommendations_divergent!bdp_sh', 'pdev-bdp_SH'),
('!i!recommendations_divergent!bdp_so', 'pdev-bdp_SO'),
('!i!recommendations_divergent!bdp_sz', 'pdev-bdp_SZ'),
('!i!recommendations_divergent!bdp_tg', 'pdev-bdp_TG'),
('!i!recommendations_divergent!bdp_ti', 'pdev-bdp_TI'),
('!i!recommendations_divergent!bdp_ur', 'pdev-bdp_UR'),
('!i!recommendations_divergent!bdp_vd', 'pdev-bdp_VD'),
('!i!recommendations_divergent!bdp_vs', 'pdev-bdp_VS'),
('!i!recommendations_divergent!bdp_vsr', 'pdev-bdp_VSr'),
('!i!recommendations_divergent!bdp_vso', 'pdev-bdp_VSo'),
('!i!recommendations_divergent!bdp_zg', 'pdev-bdp_ZG'),
('!i!recommendations_divergent!bdp_zh', 'pdev-bdp_ZH'),
('!i!recommendations_divergent!jbdp_ch', 'pdev-jbdp_CH'),
('!i!recommendations_divergent!csp_fr', 'pdev-csp_FR'),
('!i!recommendations_divergent!csp_gr', 'pdev-csp_GR'),
('!i!recommendations_divergent!csp_ju', 'pdev-csp_JU'),
('!i!recommendations_divergent!csp_lu', 'pdev-csp_LU'),
('!i!recommendations_divergent!csp_ow', 'pdev-csp_OW'),
('!i!recommendations_divergent!csp_sg', 'pdev-csp_SG'),
('!i!recommendations_divergent!csp_vs', 'pdev-csp_VS'),
('!i!recommendations_divergent!csp_vsr', 'pdev-csp_VSr'),
('!i!recommendations_divergent!csp_vso', 'pdev-csp_VSo'),
('!i!recommendations_divergent!csp_zh', 'pdev-csp_ZH'),
('!i!recommendations_divergent!cvp-fr_ch', 'pdev-cvp_frauen'),
('!i!recommendations_divergent!cvp_ag', 'pdev-cvp_AG'),
('!i!recommendations_divergent!cvp_ai', 'pdev-cvp_AI'),
('!i!recommendations_divergent!cvp_ar', 'pdev-cvp_AR'),
('!i!recommendations_divergent!cvp_be', 'pdev-cvp_BE'),
('!i!recommendations_divergent!cvp_bl', 'pdev-cvp_BL'),
('!i!recommendations_divergent!cvp_bs', 'pdev-cvp_BS'),
('!i!recommendations_divergent!cvp_fr', 'pdev-cvp_FR'),
('!i!recommendations_divergent!cvp_ge', 'pdev-cvp_GE'),
('!i!recommendations_divergent!cvp_gl', 'pdev-cvp_GL'),
('!i!recommendations_divergent!cvp_gr', 'pdev-cvp_GR'),
('!i!recommendations_divergent!cvp_ju', 'pdev-cvp_JU'),
('!i!recommendations_divergent!cvp_lu', 'pdev-cvp_LU'),
('!i!recommendations_divergent!cvp_ne', 'pdev-cvp_NE'),
('!i!recommendations_divergent!cvp_nw', 'pdev-cvp_NW'),
('!i!recommendations_divergent!cvp_ow', 'pdev-cvp_OW'),
('!i!recommendations_divergent!cvp_sg', 'pdev-cvp_SG'),
('!i!recommendations_divergent!cvp_sh', 'pdev-cvp_SH'),
('!i!recommendations_divergent!cvp_so', 'pdev-cvp_SO'),
('!i!recommendations_divergent!cvp_sz', 'pdev-cvp_SZ'),
('!i!recommendations_divergent!cvp_tg', 'pdev-cvp_TG'),
('!i!recommendations_divergent!cvp_ti', 'pdev-cvp_TI'),
('!i!recommendations_divergent!cvp_ur', 'pdev-cvp_UR'),
('!i!recommendations_divergent!cvp_vd', 'pdev-cvp_VD'),
('!i!recommendations_divergent!cvp_vs', 'pdev-cvp_VS'),
('!i!recommendations_divergent!cvp_vsr', 'pdev-cvp_VSr'),
('!i!recommendations_divergent!cvp_vso', 'pdev-cvp_VSo'),
('!i!recommendations_divergent!cvp_zg', 'pdev-cvp_ZG'),
('!i!recommendations_divergent!cvp_zh', 'pdev-cvp_ZH'),
('!i!recommendations_divergent!jcvp_ch', 'pdev-jcvp_CH'),
('!i!recommendations_divergent!jcvp_ag', 'pdev-jcvp_AG'),
('!i!recommendations_divergent!jcvp_be', 'pdev-jcvp_BE'),
('!i!recommendations_divergent!jcvp_gr', 'pdev-jcvp_GR'),
('!i!recommendations_divergent!jcvp_lu', 'pdev-jcvp_LU'),
('!i!recommendations_divergent!jcvp_so', 'pdev-jcvp_SO'),
('!i!recommendations_divergent!jcvp_zh', 'pdev-jcvp_ZH'),
('!i!recommendations_divergent!edu_ag', 'pdev-edu_AG'),
('!i!recommendations_divergent!edu_ai', 'pdev-edu_AI'),
('!i!recommendations_divergent!edu_ar', 'pdev-edu_AR'),
('!i!recommendations_divergent!edu_be', 'pdev-edu_BE'),
('!i!recommendations_divergent!edu_bl', 'pdev-edu_BL'),
('!i!recommendations_divergent!edu_bs', 'pdev-edu_BS'),
('!i!recommendations_divergent!edu_fr', 'pdev-edu_FR'),
('!i!recommendations_divergent!edu_ge', 'pdev-edu_GE'),
('!i!recommendations_divergent!edu_gl', 'pdev-edu_GL'),
('!i!recommendations_divergent!edu_gr', 'pdev-edu_GR'),
('!i!recommendations_divergent!edu_ju', 'pdev-edu_JU'),
('!i!recommendations_divergent!edu_lu', 'pdev-edu_LU'),
('!i!recommendations_divergent!edu_ne', 'pdev-edu_NE'),
('!i!recommendations_divergent!edu_nw', 'pdev-edu_NW'),
('!i!recommendations_divergent!edu_ow', 'pdev-edu_OW'),
('!i!recommendations_divergent!edu_sg', 'pdev-edu_SG'),
('!i!recommendations_divergent!edu_sh', 'pdev-edu_SH'),
('!i!recommendations_divergent!edu_so', 'pdev-edu_SO'),
('!i!recommendations_divergent!edu_sz', 'pdev-edu_SZ'),
('!i!recommendations_divergent!edu_tg', 'pdev-edu_TG'),
('!i!recommendations_divergent!edu_ti', 'pdev-edu_TI'),
('!i!recommendations_divergent!edu_ur', 'pdev-edu_UR'),
('!i!recommendations_divergent!edu_vd', 'pdev-edu_VD'),
('!i!recommendations_divergent!edu_vs', 'pdev-edu_VS'),
('!i!recommendations_divergent!edu_vsr', 'pdev-edu_VSr'),
('!i!recommendations_divergent!edu_vso', 'pdev-edu_VSo'),
('!i!recommendations_divergent!edu_zg', 'pdev-edu_ZG'),
('!i!recommendations_divergent!edu_zh', 'pdev-edu_ZH'),
('!i!recommendations_divergent!evp_ag', 'pdev-evp_AG'),
('!i!recommendations_divergent!evp_ai', 'pdev-evp_AI'),
('!i!recommendations_divergent!evp_ar', 'pdev-evp_AR'),
('!i!recommendations_divergent!evp_be', 'pdev-evp_BE'),
('!i!recommendations_divergent!evp_bl', 'pdev-evp_BL'),
('!i!recommendations_divergent!evp_bs', 'pdev-evp_BS'),
('!i!recommendations_divergent!evp_fr', 'pdev-evp_FR'),
('!i!recommendations_divergent!evp_ge', 'pdev-evp_GE'),
('!i!recommendations_divergent!evp_gl', 'pdev-evp_GL'),
('!i!recommendations_divergent!evp_gr', 'pdev-evp_GR'),
('!i!recommendations_divergent!evp_ju', 'pdev-evp_JU'),
('!i!recommendations_divergent!evp_lu', 'pdev-evp_LU'),
('!i!recommendations_divergent!evp_ne', 'pdev-evp_NE'),
('!i!recommendations_divergent!evp_nw', 'pdev-evp_NW'),
('!i!recommendations_divergent!evp_ow', 'pdev-evp_OW'),
('!i!recommendations_divergent!evp_sg', 'pdev-evp_SG'),
('!i!recommendations_divergent!evp_sh', 'pdev-evp_SH'),
('!i!recommendations_divergent!evp_so', 'pdev-evp_SO'),
('!i!recommendations_divergent!evp_sz', 'pdev-evp_SZ'),
('!i!recommendations_divergent!evp_tg', 'pdev-evp_TG'),
('!i!recommendations_divergent!evp_ti', 'pdev-evp_TI'),
('!i!recommendations_divergent!evp_ur', 'pdev-evp_UR'),
('!i!recommendations_divergent!evp_vd', 'pdev-evp_VD'),
('!i!recommendations_divergent!evp_vs', 'pdev-evp_VS'),
('!i!recommendations_divergent!evp_zg', 'pdev-evp_ZG'),
('!i!recommendations_divergent!evp_zh', 'pdev-evp_ZH'),
('!i!recommendations_divergent!jevp_ch', 'pdev-jevp_CH'),
('!i!recommendations_divergent!fdp-fr_ch', 'pdev-fdp_Frauen'),
('!i!recommendations_divergent!fdp_ag', 'pdev-fdp_AG'),
('!i!recommendations_divergent!fdp_ai', 'pdev-fdp_AI'),
('!i!recommendations_divergent!fdp_ar', 'pdev-fdp_AR'),
('!i!recommendations_divergent!fdp_be', 'pdev-fdp_BE'),
('!i!recommendations_divergent!fdp_bl', 'pdev-fdp_BL'),
('!i!recommendations_divergent!fdp_bs', 'pdev-fdp_BS'),
('!i!recommendations_divergent!fdp_fr', 'pdev-fdp_FR'),
('!i!recommendations_divergent!fdp_ge', 'pdev-fdp_GE'),
('!i!recommendations_divergent!fdp_gl', 'pdev-fdp_GL'),
('!i!recommendations_divergent!fdp_gr', 'pdev-fdp_GR'),
('!i!recommendations_divergent!fdp_ju', 'pdev-fdp_JU'),
('!i!recommendations_divergent!fdp_lu', 'pdev-fdp_LU'),
('!i!recommendations_divergent!fdp_ne', 'pdev-fdp_NE'),
('!i!recommendations_divergent!fdp_nw', 'pdev-fdp_NW'),
('!i!recommendations_divergent!fdp_ow', 'pdev-fdp_OW'),
('!i!recommendations_divergent!fdp_sg', 'pdev-fdp_SG'),
('!i!recommendations_divergent!fdp_sh', 'pdev-fdp_SH'),
('!i!recommendations_divergent!fdp_so', 'pdev-fdp_SO'),
('!i!recommendations_divergent!fdp_sz', 'pdev-fdp_SZ'),
('!i!recommendations_divergent!fdp_tg', 'pdev-fdp_TG'),
('!i!recommendations_divergent!fdp_ti', 'pdev-fdp_TI'),
('!i!recommendations_divergent!fdp_ur', 'pdev-fdp_UR'),
('!i!recommendations_divergent!fdp_vd', 'pdev-fdp_VD'),
('!i!recommendations_divergent!fdp_vs', 'pdev-fdp_VS'),
('!i!recommendations_divergent!fdp_vsr', 'pdev-fdp_VSr'),
('!i!recommendations_divergent!fdp_vso', 'pdev-fdp_Vso'),
('!i!recommendations_divergent!fdp_zg', 'pdev-fdp_ZG'),
('!i!recommendations_divergent!fdp_zh', 'pdev-fdp_ZH'),
('!i!recommendations_divergent!jfdp_ch', 'pdev-jfdp_CH'),
('!i!recommendations_divergent!jfdp_ag', 'pdev-jfdp_AG'),
('!i!recommendations_divergent!jfdp_bl', 'pdev-jfdp_BL'),
('!i!recommendations_divergent!jfdp_fr', 'pdev-jfdp_FR'),
('!i!recommendations_divergent!jfdp_gr', 'pdev-jfdp_GR'),
('!i!recommendations_divergent!jfdp_ju', 'pdev-jfdp_JU'),
('!i!recommendations_divergent!jfdp_lu', 'pdev-jfdp_LU'),
('!i!recommendations_divergent!jfdp_sh', 'pdev-jfdp_SH'),
('!i!recommendations_divergent!jfdp_ti', 'pdev-jfdp_TI'),
('!i!recommendations_divergent!jfdp_vd', 'pdev-jfdp_VD'),
('!i!recommendations_divergent!jfdp_zh', 'pdev-jfdp_ZH'),
('!i!recommendations_divergent!fps_ag', 'pdev-fps_AG'),
('!i!recommendations_divergent!fps_ai', 'pdev-fps_AI'),
('!i!recommendations_divergent!fps_be', 'pdev-fps_BE'),
('!i!recommendations_divergent!fps_bl', 'pdev-fps_BL'),
('!i!recommendations_divergent!fps_bs', 'pdev-fps_BS'),
('!i!recommendations_divergent!fps_sg', 'pdev-fps_SG'),
('!i!recommendations_divergent!fps_sh', 'pdev-fps_SH'),
('!i!recommendations_divergent!fps_so', 'pdev-fps_SO'),
('!i!recommendations_divergent!fps_tg', 'pdev-fps_TG'),
('!i!recommendations_divergent!fps_zh', 'pdev-fps_ZH'),
('!i!recommendations_divergent!glp_ag', 'pdev-glp_AG'),
('!i!recommendations_divergent!glp_ai', 'pdev-glp_AI'),
('!i!recommendations_divergent!glp_ar', 'pdev-glp_AR'),
('!i!recommendations_divergent!glp_be', 'pdev-glp_BE'),
('!i!recommendations_divergent!glp_bl', 'pdev-glp_BL'),
('!i!recommendations_divergent!glp_bs', 'pdev-glp_BS'),
('!i!recommendations_divergent!glp_fr', 'pdev-glp_FR'),
('!i!recommendations_divergent!glp_ge', 'pdev-glp_GE'),
('!i!recommendations_divergent!glp_gl', 'pdev-glp_GL'),
('!i!recommendations_divergent!glp_gr', 'pdev-glp_GR'),
('!i!recommendations_divergent!glp_ju', 'pdev-glp_JU'),
('!i!recommendations_divergent!glp_lu', 'pdev-glp_LU'),
('!i!recommendations_divergent!glp_ne', 'pdev-glp_NE'),
('!i!recommendations_divergent!glp_nw', 'pdev-glp_NW'),
('!i!recommendations_divergent!glp_ow', 'pdev-glp_OW'),
('!i!recommendations_divergent!glp_sg', 'pdev-glp_SG'),
('!i!recommendations_divergent!glp_sh', 'pdev-glp_SH'),
('!i!recommendations_divergent!glp_so', 'pdev-glp_SO'),
('!i!recommendations_divergent!glp_sz', 'pdev-glp_SZ'),
('!i!recommendations_divergent!glp_tg', 'pdev-glp_TG'),
('!i!recommendations_divergent!glp_ti', 'pdev-glp_TI'),
('!i!recommendations_divergent!glp_ur', 'pdev-glp_UR'),
('!i!recommendations_divergent!glp_vd', 'pdev-glp_VD'),
('!i!recommendations_divergent!glp_vs', 'pdev-glp_VS'),
('!i!recommendations_divergent!glp_vsr', 'pdev-glp_VSr'),
('!i!recommendations_divergent!glp_vso', 'pdev-glp_VSo'),
('!i!recommendations_divergent!glp_zg', 'pdev-glp_ZG'),
('!i!recommendations_divergent!glp_zh', 'pdev-glp_ZH'),
('!i!recommendations_divergent!jglp_ch', 'pdev-jglp_CH'),
('!i!recommendations_divergent!gps_ag', 'pdev-gps_AG'),
('!i!recommendations_divergent!gps_ai', 'pdev-gps_AI'),
('!i!recommendations_divergent!gps_ar', 'pdev-gps_AR'),
('!i!recommendations_divergent!gps_be', 'pdev-gps_BE'),
('!i!recommendations_divergent!gps_bl', 'pdev-gps_BL'),
('!i!recommendations_divergent!gps_bs', 'pdev-gps_BS'),
('!i!recommendations_divergent!gps_fr', 'pdev-gps_FR'),
('!i!recommendations_divergent!gps_ge', 'pdev-gps_GE'),
('!i!recommendations_divergent!gps_gl', 'pdev-gps_GL'),
('!i!recommendations_divergent!gps_gr', 'pdev-gps_GR'),
('!i!recommendations_divergent!gps_ju', 'pdev-gps_JU'),
('!i!recommendations_divergent!gps_lu', 'pdev-gps_LU'),
('!i!recommendations_divergent!gps_ne', 'pdev-gps_NE'),
('!i!recommendations_divergent!gps_nw', 'pdev-gps_NW'),
('!i!recommendations_divergent!gps_ow', 'pdev-gps_OW'),
('!i!recommendations_divergent!gps_sg', 'pdev-gps_SG'),
('!i!recommendations_divergent!gps_sh', 'pdev-gps_SH'),
('!i!recommendations_divergent!gps_so', 'pdev-gps_SO'),
('!i!recommendations_divergent!gps_sz', 'pdev-gps_SZ'),
('!i!recommendations_divergent!gps_tg', 'pdev-gps_TG'),
('!i!recommendations_divergent!gps_ti', 'pdev-gps_TI'),
('!i!recommendations_divergent!gps_ur', 'pdev-gps_UR'),
('!i!recommendations_divergent!gps_vd', 'pdev-gps_VD'),
('!i!recommendations_divergent!gps_vs', 'pdev-gps_VS'),
('!i!recommendations_divergent!gps_vsr', 'pdev-gps_VSr'),
('!i!recommendations_divergent!gps_vso', 'pdev-gps_VSo'),
('!i!recommendations_divergent!gps_zg', 'pdev-gps_ZG'),
('!i!recommendations_divergent!gps_zh', 'pdev-gps_ZH'),
('!i!recommendations_divergent!jgps_ch', 'pdev-jgps_CH'),
('!i!recommendations_divergent!kvp_sg', 'pdev-kvp_SG'),
('!i!recommendations_divergent!lps_be', 'pdev-lps_BE'),
('!i!recommendations_divergent!lps_bl', 'pdev-lps_BL'),
('!i!recommendations_divergent!lps_bs', 'pdev-lps_BS'),
('!i!recommendations_divergent!lps_fr', 'pdev-lps_FR'),
('!i!recommendations_divergent!lps_ge', 'pdev-lps_GE'),
('!i!recommendations_divergent!lps_ju', 'pdev-lps_JU'),
('!i!recommendations_divergent!lps_ne', 'pdev-lps_NE'),
('!i!recommendations_divergent!lps_sg', 'pdev-lps_SG'),
('!i!recommendations_divergent!lps_ti', 'pdev-lps_TI'),
('!i!recommendations_divergent!lps_vd', 'pdev-lps_VD'),
('!i!recommendations_divergent!lps_vs', 'pdev-lps_VS'),
('!i!recommendations_divergent!lps_zh', 'pdev-lps_ZH'),
('!i!recommendations_divergent!jlps_ch', 'pdev-jlps_CH'),
('!i!recommendations_divergent!jlps_so', 'pdev-jlps_SO'),
('!i!recommendations_divergent!jlps_ti', 'pdev-jlps_TI'),
('!i!recommendations_divergent!ldu_ag', 'pdev-ldu_AG'),
('!i!recommendations_divergent!ldu_ar', 'pdev-ldu_AR'),
('!i!recommendations_divergent!ldu_be', 'pdev-ldu_BE'),
('!i!recommendations_divergent!ldu_bl', 'pdev-ldu_BL'),
('!i!recommendations_divergent!ldu_bs', 'pdev-ldu_BS'),
('!i!recommendations_divergent!ldu_gr', 'pdev-ldu_GR'),
('!i!recommendations_divergent!ldu_lu', 'pdev-ldu_LU'),
('!i!recommendations_divergent!ldu_ne', 'pdev-ldu_NE'),
('!i!recommendations_divergent!ldu_sg', 'pdev-ldu_SG'),
('!i!recommendations_divergent!ldu_sh', 'pdev-ldu_SH'),
('!i!recommendations_divergent!ldu_so', 'pdev-ldu_SO'),
('!i!recommendations_divergent!ldu_tg', 'pdev-ldu_TG'),
('!i!recommendations_divergent!ldu_vd', 'pdev-ldu_VD'),
('!i!recommendations_divergent!ldu_zg', 'pdev-ldu_ZG'),
('!i!recommendations_divergent!ldu_zh', 'pdev-ldu_ZH'),
('!i!recommendations_divergent!jldu_ch', 'pdev-jldu_CH'),
('!i!recommendations_divergent!poch_so', 'pdev-poch_SO'),
('!i!recommendations_divergent!poch_zh', 'pdev-poch_ZH'),
('!i!recommendations_divergent!pda_be', 'pdev-pda_BE'),
('!i!recommendations_divergent!pda_bl', 'pdev-pda_BL'),
('!i!recommendations_divergent!pda_bs', 'pdev-pda_BS'),
('!i!recommendations_divergent!pda_ge', 'pdev-pda_GE'),
('!i!recommendations_divergent!pda_ju', 'pdev-pda_JU'),
('!i!recommendations_divergent!pda_ne', 'pdev-pda_NE'),
('!i!recommendations_divergent!pda_sg', 'pdev-pda_SG'),
('!i!recommendations_divergent!pda_ti', 'pdev-pda_TI'),
('!i!recommendations_divergent!pda_vd', 'pdev-pda_VD'),
('!i!recommendations_divergent!pda_zh', 'pdev-pda_ZH'),
('!i!recommendations_divergent!jpda_ch', 'pdev-jpda_CH'),
('!i!recommendations_divergent!rep_ag', 'pdev-rep_AG'),
('!i!recommendations_divergent!rep_ge', 'pdev-rep_GE'),
('!i!recommendations_divergent!rep_ne', 'pdev-rep_NE'),
('!i!recommendations_divergent!rep_tg', 'pdev-rep_TG'),
('!i!recommendations_divergent!rep_vd', 'pdev-rep_VD'),
('!i!recommendations_divergent!rep_zh', 'pdev-rep_ZH'),
('!i!recommendations_divergent!sd_ag', 'pdev-sd_AG'),
('!i!recommendations_divergent!sd_be', 'pdev-sd_BE'),
('!i!recommendations_divergent!sd_bl', 'pdev-sd_BL'),
('!i!recommendations_divergent!sd_bs', 'pdev-sd_BS'),
('!i!recommendations_divergent!sd_fr', 'pdev-sd_FR'),
('!i!recommendations_divergent!sd_ge', 'pdev-sd_GE'),
('!i!recommendations_divergent!sd_gr', 'pdev-sd_GR'),
('!i!recommendations_divergent!sd_lu', 'pdev-sd_LU'),
('!i!recommendations_divergent!sd_ne', 'pdev-sd_NE'),
('!i!recommendations_divergent!sd_sg', 'pdev-sd_SG'),
('!i!recommendations_divergent!sd_so', 'pdev-sd_SO'),
('!i!recommendations_divergent!sd_tg', 'pdev-sd_TG'),
('!i!recommendations_divergent!sd_ti', 'pdev-sd_TI'),
('!i!recommendations_divergent!sd_vd', 'pdev-sd_VD'),
('!i!recommendations_divergent!sd_zh', 'pdev-sd_ZH'),
('!i!recommendations_divergent!jsd_ch', 'pdev-jsd_CH'),
('!i!recommendations_divergent!sps_ag', 'pdev-sps_AG'),
('!i!recommendations_divergent!sps_ai', 'pdev-sps_AI'),
('!i!recommendations_divergent!sps_ar', 'pdev-sps_AR'),
('!i!recommendations_divergent!sps_be', 'pdev-sps_BE'),
('!i!recommendations_divergent!sps_bl', 'pdev-sps_BL'),
('!i!recommendations_divergent!sps_bs', 'pdev-sps_BS'),
('!i!recommendations_divergent!sps_fr', 'pdev-sps_FR'),
('!i!recommendations_divergent!sps_ge', 'pdev-sps_GE'),
('!i!recommendations_divergent!sps_gl', 'pdev-sps_GL'),
('!i!recommendations_divergent!sps_gr', 'pdev-sps_GR'),
('!i!recommendations_divergent!sps_ju', 'pdev-sps_JU'),
('!i!recommendations_divergent!sps_lu', 'pdev-sps_LU'),
('!i!recommendations_divergent!sps_ne', 'pdev-sps_NE'),
('!i!recommendations_divergent!sps_nw', 'pdev-sps_NW'),
('!i!recommendations_divergent!sps_ow', 'pdev-sps_OW'),
('!i!recommendations_divergent!sps_sg', 'pdev-sps_SG'),
('!i!recommendations_divergent!sps_sh', 'pdev-sps_SH'),
('!i!recommendations_divergent!sps_so', 'pdev-sps_SO'),
('!i!recommendations_divergent!sps_sz', 'pdev-sps_SZ'),
('!i!recommendations_divergent!sps_tg', 'pdev-sps_TG'),
('!i!recommendations_divergent!sps_ti', 'pdev-sps_TI'),
('!i!recommendations_divergent!sps_ur', 'pdev-sps_UR'),
('!i!recommendations_divergent!sps_vd', 'pdev-sps_VD'),
('!i!recommendations_divergent!sps_vs', 'pdev-sps_VS'),
('!i!recommendations_divergent!sps_vsr', 'pdev-sps_VSr'),
('!i!recommendations_divergent!sps_vso', 'pdev-sps_VSo'),
('!i!recommendations_divergent!sps_zg', 'pdev-sps_ZG'),
('!i!recommendations_divergent!sps_zh', 'pdev-sps_ZH'),
('!i!recommendations_divergent!juso_ch', 'pdev-juso_CH'),
('!i!recommendations_divergent!juso_be', 'pdev-juso_BE'),
('!i!recommendations_divergent!juso_ge', 'pdev-juso_GE'),
('!i!recommendations_divergent!juso_ju', 'pdev-juso_JU'),
('!i!recommendations_divergent!juso_ti', 'pdev-juso_TI'),
('!i!recommendations_divergent!juso_vs', 'pdev-juso_VS'),
('!i!recommendations_divergent!juso_zh', 'pdev-juso_ZH'),
('!i!recommendations_divergent!svp_ag', 'pdev-svp_AG'),
('!i!recommendations_divergent!svp_ai', 'pdev-svp_AI'),
('!i!recommendations_divergent!svp_ar', 'pdev-svp_AR'),
('!i!recommendations_divergent!svp_be', 'pdev-svp_BE'),
('!i!recommendations_divergent!svp_bl', 'pdev-svp_BL'),
('!i!recommendations_divergent!svp_bs', 'pdev-svp_BS'),
('!i!recommendations_divergent!svp_fr', 'pdev-svp_FR'),
('!i!recommendations_divergent!svp_ge', 'pdev-svp_GE'),
('!i!recommendations_divergent!svp_gl', 'pdev-svp_GL'),
('!i!recommendations_divergent!svp_gr', 'pdev-svp_GR'),
('!i!recommendations_divergent!svp_ju', 'pdev-svp_JU'),
('!i!recommendations_divergent!svp_lu', 'pdev-svp_LU'),
('!i!recommendations_divergent!svp_ne', 'pdev-svp_NE'),
('!i!recommendations_divergent!svp_nw', 'pdev-svp_NW'),
('!i!recommendations_divergent!svp_ow', 'pdev-svp_OW'),
('!i!recommendations_divergent!svp_sg', 'pdev-svp_SG'),
('!i!recommendations_divergent!svp_sh', 'pdev-svp_SH'),
('!i!recommendations_divergent!svp_so', 'pdev-svp_SO'),
('!i!recommendations_divergent!svp_sz', 'pdev-svp_SZ'),
('!i!recommendations_divergent!svp_tg', 'pdev-svp_TG'),
('!i!recommendations_divergent!svp_ti', 'pdev-svp_TI'),
('!i!recommendations_divergent!svp_ur', 'pdev-svp_UR'),
('!i!recommendations_divergent!svp_vd', 'pdev-svp_VD'),
('!i!recommendations_divergent!svp_vs', 'pdev-svp_VS'),
('!i!recommendations_divergent!svp_vsr', 'pdev-svp_VSr'),
('!i!recommendations_divergent!svp_vso', 'pdev-svp_VSo'),
('!i!recommendations_divergent!svp_zg', 'pdev-svp_ZG'),
('!i!recommendations_divergent!svp_zh', 'pdev-svp_ZH'),
('!i!recommendations_divergent!jsvp_ch', 'pdev-jsvp_CH'),
('!i!recommendations_divergent!jsvp_ag', 'pdev-jsvp_AG'),
('!i!recommendations_divergent!jsvp_be', 'pdev-jsvp_BE'),
('!i!recommendations_divergent!jsvp_ge', 'pdev-jsvp_GE'),
('!i!recommendations_divergent!jsvp_sh', 'pdev-jsvp_SH'),
('!i!recommendations_divergent!jsvp_ur', 'pdev-jsvp_UR'),
('!i!recommendations_divergent!jsvp_zh', 'pdev-jsvp_ZH'),
('!i!recommendations_divergent!sgb_ag', 'pdev-sgb_AG'),
('!i!recommendations_divergent!sgb_ju', 'pdev-sgb_JU'),
('!i!recommendations_divergent!sgb_vs', 'pdev-sgb_VS'),
('!i!recommendations_divergent!sgv_ag', 'pdev-sgv_AG'),
('!i!recommendations_divergent!sgv_bs', 'pdev-sgv_BS'),
('!i!recommendations_divergent!sgv_sh', 'pdev-sgv_SH'),
('!i!recommendations_divergent!vpod_ge', 'pdev-vpod_GE'),
('!i!recommendations_divergent!vpod_vd', 'pdev-vpod_VD'),
('!i!recommendations_divergent!mitte-fr_ch', 'pdev-mitte_frauen'),
('!i!recommendations_divergent!mitte_ag', 'pdev-mitte_AG'),
('!i!recommendations_divergent!mitte_ai', 'pdev-mitte_AI'),
('!i!recommendations_divergent!mitte_ar', 'pdev-mitte_AR'),
('!i!recommendations_divergent!mitte_be', 'pdev-mitte_BE'),
('!i!recommendations_divergent!mitte_bl', 'pdev-mitte_BL'),
('!i!recommendations_divergent!mitte_bs', 'pdev-mitte_BS'),
('!i!recommendations_divergent!mitte_fr', 'pdev-mitte_FR'),
('!i!recommendations_divergent!mitte_ge', 'pdev-mitte_GE'),
('!i!recommendations_divergent!mitte_gl', 'pdev-mitte_GL'),
('!i!recommendations_divergent!mitte_gr', 'pdev-mitte_GR'),
('!i!recommendations_divergent!mitte_ju', 'pdev-mitte_JU'),
('!i!recommendations_divergent!mitte_lu', 'pdev-mitte_LU'),
('!i!recommendations_divergent!mitte_ne', 'pdev-mitte_NE'),
('!i!recommendations_divergent!mitte_nw', 'pdev-mitte_NW'),
('!i!recommendations_divergent!mitte_ow', 'pdev-mitte_OW'),
('!i!recommendations_divergent!mitte_sg', 'pdev-mitte_SG'),
('!i!recommendations_divergent!mitte_sh', 'pdev-mitte_SH'),
('!i!recommendations_divergent!mitte_so', 'pdev-mitte_SO'),
('!i!recommendations_divergent!mitte_sz', 'pdev-mitte_SZ'),
('!i!recommendations_divergent!mitte_tg', 'pdev-mitte_TG'),
('!i!recommendations_divergent!mitte_ti', 'pdev-mitte_TI'),
('!i!recommendations_divergent!mitte_ur', 'pdev-mitte_UR'),
('!i!recommendations_divergent!mitte_vd', 'pdev-mitte_VD'),
('!i!recommendations_divergent!mitte_vs', 'pdev-mitte_VS'),
('!i!recommendations_divergent!mitte_vsr', 'pdev-mitte_VSr'),
('!i!recommendations_divergent!mitte_vso', 'pdev-mitte_VSo'),
('!i!recommendations_divergent!mitte_zg', 'pdev-mitte_ZG'),
('!i!recommendations_divergent!mitte_zh', 'pdev-mitte_ZH'),
('!i!recommendations_divergent!jmitte_ch', 'pdev-jmitte_CH'),
('!i!recommendations_divergent!jmitte_ag', 'pdev-jmitte_AG'),
('!i!recommendations_divergent!jmitte_ai', 'pdev-jmitte_AI'),
('!i!recommendations_divergent!jmitte_ar', 'pdev-jmitte_AR'),
('!i!recommendations_divergent!jmitte_be', 'pdev-jmitte_BE'),
('!i!recommendations_divergent!jmitte_bl', 'pdev-jmitte_BL'),
('!i!recommendations_divergent!jmitte_bs', 'pdev-jmitte_BS'),
('!i!recommendations_divergent!jmitte_fr', 'pdev-jmitte_FR'),
('!i!recommendations_divergent!jmitte_ge', 'pdev-jmitte_GE'),
('!i!recommendations_divergent!jmitte_gl', 'pdev-jmitte_GL'),
('!i!recommendations_divergent!jmitte_gr', 'pdev-jmitte_GR'),
('!i!recommendations_divergent!jmitte_ju', 'pdev-jmitte_JU'),
('!i!recommendations_divergent!jmitte_lu', 'pdev-jmitte_LU'),
('!i!recommendations_divergent!jmitte_ne', 'pdev-jmitte_NE'),
('!i!recommendations_divergent!jmitte_nw', 'pdev-jmitte_NW'),
('!i!recommendations_divergent!jmitte_ow', 'pdev-jmitte_OW'),
('!i!recommendations_divergent!jmitte_sg', 'pdev-jmitte_SG'),
('!i!recommendations_divergent!jmitte_sh', 'pdev-jmitte_SH'),
('!i!recommendations_divergent!jmitte_so', 'pdev-jmitte_SO'),
('!i!recommendations_divergent!jmitte_sz', 'pdev-jmitte_SZ'),
('!i!recommendations_divergent!jmitte_tg', 'pdev-jmitte_TG'),
('!i!recommendations_divergent!jmitte_ti', 'pdev-jmitte_TI'),
('!i!recommendations_divergent!jmitte_ur', 'pdev-jmitte_UR'),
('!i!recommendations_divergent!jmitte_vd', 'pdev-jmitte_VD'),
('!i!recommendations_divergent!jmitte_vs', 'pdev-jmitte_VS'),
('!i!recommendations_divergent!jmitte_vsr', 'pdev-jmitte_VSr'),
('!i!recommendations_divergent!jmitte_vso', 'pdev-jmitte_VSo'),
('!i!recommendations_divergent!jmitte_zg', 'pdev-jmitte_ZG'),
('!i!recommendations_divergent!jmitte_zh', 'pdev-jmitte_ZH'),
('national_council_election_year', 'nr-wahl'),
('national_council_share_fdp', 'w-fdp'),
('national_council_share_cvp', 'w-cvp'),
('national_council_share_sps', 'w-sp'),
('national_council_share_svp', 'w-svp'),
('national_council_share_evp', 'w-evp'),
('national_council_share_csp', 'w-csp'),
('national_council_share_pda', 'w-pda'),
('national_council_share_gps', 'w-gps'),
('national_council_share_sd', 'w-sd'),
('national_council_share_edu', 'w-edu'),
('national_council_share_fps', 'w-fps'),
('national_council_share_lega', 'w-lega'),
('national_council_share_kvp', 'w-kvp'),
('national_council_share_glp', 'w-glp'),
('national_council_share_bdp', 'w-bdp'),
('national_council_share_mcg', 'w-mcg'),
('national_council_share_lps', 'w-lps'),
('national_council_share_ldu', 'w-ldu'),
('national_council_share_poch', 'w-poch'),
('national_council_share_rep', 'w-rep'),
('national_council_share_mitte', 'w-mitte'),
('national_council_share_ubrige', 'w-ubrige'),
('national_council_share_yeas', 'ja-lager'), # 1
('national_council_share_nays', 'nein-lager'), # 2
('national_council_share_none', 'keinepar-summe'), # 3
('national_council_share_empty', 'leer-summe'), # 4
('national_council_share_free_vote', 'freigabe-summe'), # 5
('national_council_share_neutral', 'neutral-summe'), # 66
('national_council_share_unknown', 'unbekannt-summe'),
('posters_mfg_yea', 'poster_ja_mfg'),
('posters_mfg_nay', 'poster_nein_mfg'),
('posters_bs_yea', 'poster_ja_bs'),
('posters_bs_nay', 'poster_nein_bs'),
('posters_sa_yea', 'poster_ja_sa'),
('posters_sa_nay', 'poster_nein_sa'),
('_result_people_accepted', 'volk'),
('_result_cantons_accepted', 'stand'),
('_result', 'annahme'),
('result_turnout', 'bet'),
('result_people_yeas_p', 'volkja-proz'),
('result_cantons_yeas', 'kt-ja'),
('result_cantons_nays', 'kt-nein'),
('_result_zh_accepted', 'zh-annahme'),
('_result_be_accepted', 'be-annahme'),
('_result_lu_accepted', 'lu-annahme'),
('_result_ur_accepted', 'ur-annahme'),
('_result_sz_accepted', 'sz-annahme'),
('_result_ow_accepted', 'ow-annahme'),
('_result_nw_accepted', 'nw-annahme'),
('_result_gl_accepted', 'gl-annahme'),
('_result_zg_accepted', 'zg-annahme'),
('_result_fr_accepted', 'fr-annahme'),
('_result_so_accepted', 'so-annahme'),
('_result_bs_accepted', 'bs-annahme'),
('_result_bl_accepted', 'bl-annahme'),
('_result_sh_accepted', 'sh-annahme'),
('_result_ar_accepted', 'ar-annahme'),
('_result_ai_accepted', 'ai-annahme'),
('_result_sg_accepted', 'sg-annahme'),
('_result_gr_accepted', 'gr-annahme'),
('_result_ag_accepted', 'ag-annahme'),
('_result_tg_accepted', 'tg-annahme'),
('_result_ti_accepted', 'ti-annahme'),
('_result_vd_accepted', 'vd-annahme'),
('_result_vs_accepted', 'vs-annahme'),
('_result_ne_accepted', 'ne-annahme'),
('_result_ge_accepted', 'ge-annahme'),
('_result_ju_accepted', 'ju-annahme'),
('!t!content!link_bk_results_de', 'bkresults-de'),
('!t!content!link_bk_results_fr', 'bkresults-fr'),
('!t!content!link_federal_council_de', 'info_br-de'),
('!t!content!link_federal_council_fr', 'info_br-fr'),
('!t!content!link_federal_council_en', 'info_br-en'),
('!t!content!link_federal_departement_de', 'info_dep-de'),
('!t!content!link_federal_departement_fr', 'info_dep-fr'),
('!t!content!link_federal_departement_en', 'info_dep-en'),
('!t!content!link_federal_office_de', 'info_amt-de'),
('!t!content!link_federal_office_fr', 'info_amt-fr'),
('!t!content!link_federal_office_en', 'info_amt-en'),
('bfs_map_de', 'bfsmap-de'),
('bfs_map_fr', 'bfsmap-fr'),
('bfs_map_en', 'bfsmap-en'),
('bfs_dashboard_de', 'bfsdash-de'),
('bfs_dashboard_fr', 'bfsdash-fr'),
('bfs_dashboard_en', 'bfsdash-en'),
('media_ads_total', 'inserate-total'),
('media_ads_yea_p', 'inserate-jaanteil'),
('media_coverage_articles_total', 'mediares-tot'),
('media_coverage_tonality_total', 'mediaton-tot'),
('!t!content!link_post_vote_poll_de', 'nach_cockpit_d'),
('!t!content!link_post_vote_poll_fr', 'nach_cockpit_f'),
('!t!content!link_post_vote_poll_en', 'nach_cockpit_e'),
('procedure_number', 'gesch_nr'),
('brief_description_title', 'kurzbetitel'),
('!t!content!link_easyvote_de', 'easyvideo_de'),
('!t!content!link_easyvote_fr', 'easyvideo_fr'),
('!t!content!link_campaign_yes_1_de', 'web-yes-1-de'),
('!t!content!link_campaign_yes_1_fr', 'web-yes-1-fr'),
('!t!content!link_campaign_yes_2_de', 'web-yes-2-de'),
('!t!content!link_campaign_yes_2_fr', 'web-yes-2-fr'),
('!t!content!link_campaign_yes_3_de', 'web-yes-3-de'),
('!t!content!link_campaign_yes_3_fr', 'web-yes-3-fr'),
('!t!content!link_campaign_no_1_de', 'web-no-1-de'),
('!t!content!link_campaign_no_1_fr', 'web-no-1-fr'),
('!t!content!link_campaign_no_2_de', 'web-no-2-de'),
('!t!content!link_campaign_no_2_fr', 'web-no-2-fr'),
('!t!content!link_campaign_no_3_de', 'web-no-3-de'),
('!t!content!link_campaign_no_3_fr', 'web-no-3-fr'),
('campaign_finances_yea_total', 'finanz-ja-tot'),
('campaign_finances_nay_total', 'finanz-nein-tot'),
('!t!content!campaign_finances_yea_donors_de', 'finanz-ja-gr-de'),
('!t!content!campaign_finances_yea_donors_fr', 'finanz-ja-gr-fr'),
('!t!content!campaign_finances_nay_donors_de',
'finanz-nein-gr-de'),
('!t!content!campaign_finances_nay_donors_fr',
'finanz-nein-gr-fr'),
('!t!content!campaign_finances_link_de', 'finanz-link-de'),
('!t!content!campaign_finances_link_fr', 'finanz-link-fr'),
))
[docs]
def set_value(self, vote: SwissVote, attribute: str, value: Any) -> None:
""" Set the given value of a vote. """
if attribute.startswith('!'):
_, _type, attribute, key = attribute.split('!')
if getattr(vote, attribute) is None:
setattr(vote, attribute, {})
getattr(vote, attribute)[key] = value
else:
setattr(vote, attribute, value)
[docs]
def get_value(self, vote: SwissVote, attribute: str) -> Any:
""" Get the given value of a vote. """
if attribute.startswith('!'):
_, _type, attribute, key = attribute.split('!')
return (getattr(vote, attribute) or {}).get(key)
return getattr(vote, attribute)
[docs]
def get_values(self, vote: SwissVote) -> 'Iterator[Any]':
""" Get all values of a vote in order. """
for attribute in self.columns.keys():
yield self.get_value(vote, attribute)
[docs]
def get_items(self, vote: SwissVote) -> 'Iterator[tuple[str, Any]]':
""" Get all names and values of a vote in order. """
for attribute in self.columns.keys():
yield attribute, self.get_value(vote, attribute)
[docs]
def items(self) -> 'Iterator[ColumnItem]':
""" Returns the attributes and column names together with additional
information (type, nullable, precision, scale).
"""
for attribute, column in self.columns.items():
if attribute.startswith('!'):
type_ = {'i': 'INTEGER', 't': 'TEXT'}.get(
attribute.split('!')[1]
)
nullable = True
precision = None
scale = None
else:
name = attribute.lstrip('_')
table_column = SwissVote.__table__.columns[name]
type_ = str(table_column.type)
nullable = table_column.nullable
precision = getattr(table_column.type, 'precision', None)
scale = getattr(table_column.type, 'scale', None)
yield attribute, column, type_, nullable, precision, scale