64 lines
1.3 KiB
Python
64 lines
1.3 KiB
Python
|
|
"""測試用的合成資料:中選會各檔的列與參選紀錄。"""
|
|||
|
|
|
|||
|
|
from __future__ import annotations
|
|||
|
|
|
|||
|
|
from dataclasses import replace
|
|||
|
|
|
|||
|
|
from election_data.records.parse import Run
|
|||
|
|
|
|||
|
|
BASE = Run(
|
|||
|
|
folder="2022/T1",
|
|||
|
|
year=2022,
|
|||
|
|
date="2022-11-26",
|
|||
|
|
election="直轄市議員",
|
|||
|
|
office="councilor",
|
|||
|
|
indigenous=None,
|
|||
|
|
county="臺北市",
|
|||
|
|
county_code="63000",
|
|||
|
|
district="第1選區",
|
|||
|
|
area=("63", "000"),
|
|||
|
|
district_code="01",
|
|||
|
|
number=1,
|
|||
|
|
name="王小明",
|
|||
|
|
party="甲黨",
|
|||
|
|
gender="M",
|
|||
|
|
birth_year=1970,
|
|||
|
|
votes=10_000,
|
|||
|
|
share=0.1,
|
|||
|
|
elected=True,
|
|||
|
|
incumbent=False,
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
|
|||
|
|
def run(**changes: object) -> Run:
|
|||
|
|
return replace(BASE, **changes) # type: ignore[arg-type]
|
|||
|
|
|
|||
|
|
|
|||
|
|
def cand(
|
|||
|
|
prv: str, city: str, district: str, number: str, name: str, party: str, birth: str, elected: str = ""
|
|||
|
|
) -> list[str]:
|
|||
|
|
"""elcand 的一列(16 欄)"""
|
|||
|
|
return [
|
|||
|
|
prv,
|
|||
|
|
city,
|
|||
|
|
district,
|
|||
|
|
"000",
|
|||
|
|
"0000",
|
|||
|
|
number,
|
|||
|
|
name,
|
|||
|
|
party,
|
|||
|
|
"1",
|
|||
|
|
birth,
|
|||
|
|
"50",
|
|||
|
|
"",
|
|||
|
|
"",
|
|||
|
|
"N",
|
|||
|
|
elected,
|
|||
|
|
"",
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
|
|||
|
|
def total(prv: str, city: str, district: str, number: str, votes: int, station: str = "0000") -> list[str]:
|
|||
|
|
"""elctks 的選區總計列"""
|
|||
|
|
return [prv, city, district, "000", "0000", station, number, str(votes), "", ""]
|