Add EP amendment and part votes, hidden from general lists by default

They come from the same responses as final votes. A sitting has over a
hundred, so they are flagged part_vote and only appear on request: the vote
lists have an option for them, feeds, counts and search chunks leave them out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
simonandClaude Opus 5.5 committed 2026-11-09 13:17:10 +01:00
1 parent bf19e503f9
commit b06f17e587
20 files changed
+176 -47

No files matched your search

+20 -12
View File
@@ -200,6 +200,7 @@ class EuropeanParliament(Adapter):
LD_JSON = "application/ld+json"
EP_DECISIONS_PAGE = 500
EP_REFERENCE = re.compile(r"^[AB]\d+-\d+/\d{4}$")
EP_OUTCOME = {"ADOPTED": ("accepted", "angenommen", "adopted"), "REJECTED": ("rejected", "abgelehnt", "rejected")}
EP_VOTERS = (("had_voter_favor", "for", "Stimmte für", "Voted for"),
("had_voter_against", "against", "Stimmte gegen", "Voted against"),
@@ -220,18 +221,19 @@ def ep_person_ids(values: list[str] | None) -> set[str]:
@register
class ParliamentVotes(Adapter):
"""Final roll-call votes (whole texts, no amendments) of the Austrian MEPs known to the database.
"""Roll-call votes of the Austrian MEPs known to the database: on whole texts and on amendments or parts.
Amendment votes are left out on purpose: a sitting has over a hundred of them, which would bury
the final votes on a member's page. The official result counts; corrections MEPs file afterwards are
kept in `data.intended`, because they don't change the result.
Part votes are flagged (`VoteEvent.part_vote`, `data.part_vote`), because a sitting has over a hundred of
them and they would otherwise bury the final votes. The official result counts; corrections MEPs file
afterwards are kept in `data.intended`, because they don't change the result.
"""
spec = EP_SPEC
name = "europarl.votes"
description = "Final roll-call votes of Austrian MEPs in the European Parliament plenary"
description = "Roll-call votes of Austrian MEPs in the European Parliament plenary, including amendments"
schedule = "45 5 * * *"
queue = "scrape"
parser_version = 2 # amendment and part votes
def start(self, ctx: RunContext) -> Iterator[Request]:
ep_ids = []
@@ -277,9 +279,10 @@ class ParliamentVotes(Adapter):
austrian = set(meta["ep_ids"])
chamber = OrgRef(slug="europaeisches-parlament")
for decision in data:
if "ROLLCALL" not in str(decision.get("decision_method")) or "decisionAboutId" in decision:
ctx.stats["not_final_rollcall"] += 1
if "ROLLCALL" not in str(decision.get("decision_method")):
ctx.stats["not_rollcall"] += 1
continue
part_vote = "decisionAboutId" in decision
voters = {position: ep_person_ids(decision.get(field)) & austrian for field, position, _, _ in EP_VOTERS}
if not any(voters.values()):
ctx.stats["no_austrian_voters"] += 1
@@ -289,6 +292,9 @@ class ParliamentVotes(Adapter):
items = decision.get("inverse_consists_of") or [None]
title = meta["titles"].get(items[0]) or label
stage = ep_label(decision.get("referenceText"))
label_parts = label.split(" – ", 2) # "A10-0272/2026 – rapporteur – § 13, nach Buchstabe a – Änd. 9"
if part_vote and len(label_parts) == 3:
stage = label_parts[2]
status = str(decision.get("decision_outcome", "")).rsplit("/", 1)[-1]
result, outcome_de, outcome_en = EP_OUTCOME.get(status, ("unknown", "Ergebnis unbekannt", "outcome unknown"))
counts = {"yes": decision.get("number_of_votes_favor"), "no": decision.get("number_of_votes_against"),
@@ -301,17 +307,19 @@ class ParliamentVotes(Adapter):
if pv else None)
event_key = fingerprint("ep-vote", decision["id"])
yield VoteEvent(key=event_key, chamber=chamber, title=title, voted_on=voted_on, result=result, stage=stage,
item_ref=label.split(" – ", 1)[0], roll_call=True, url=url, protocol_url=protocol,
raw_text=f"{stage}: {tally}")
item_ref=label_parts[0] if EP_REFERENCE.match(label_parts[0]) else None, roll_call=True,
url=url, protocol_url=protocol, raw_text=f"{stage}: {tally}", part_vote=part_vote)
subject = f"{title}, {stage}" if part_vote and title != label else title # a label already names the part
intended = {mep: position for field, position in EP_INTENDED for mep in ep_person_ids(decision.get(field))}
for _, position, verb_de, verb_en in EP_VOTERS:
for mep in sorted(voters[position]):
yield Claim(
claim_type="vote", person=PersonRef(ids={"ep": mep}), counterpart_org=chamber, occurred_at=voted_on,
summary_de=f"{verb_de}: {title} (Europäisches Parlament) – {outcome_de}",
summary_en=f"{verb_en}: {title} (European Parliament) – {outcome_en}",
summary_de=f"{verb_de}: {subject} (Europäisches Parlament) – {outcome_de}",
summary_en=f"{verb_en}: {subject} (European Parliament) – {outcome_en}",
data={"position": position, "result": result, "roll_call": True, "chamber": "EP", **counts,
**({"intended": intended[mep]} if mep in intended else {})},
**({"intended": intended[mep]} if mep in intended else {}),
**({"part_vote": True} if part_vote else {})},
evidence=[Evidence(url=url, doc_type="api_record", title=title, published_at=voted_on,
quote=f"{stage}: {tally}", locator=f"vote:{decision['id']}")],
topics=("Europäische Union",),