group vote files by party and vote result

Each vote topic file now shows party headings with subheadings for
each vote result (Ja/Nein/Enthaltung), making it easy to see how
each party voted at a glance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marco Lents 2026-04-15 08:53:09 +02:00
parent e2bc067c30
commit 8470b4ba98

View file

@ -310,9 +310,23 @@ def save_votes(bios, out):
# Generate one markdown file per vote topic # Generate one markdown file per vote topic
for key, votes in sorted(all_votes.items()): for key, votes in sorted(all_votes.items()):
md = f"# {key}\n\n" md = f"# {key}\n\n"
for name in sorted(votes, key=lambda n: votes[n]["party"]): # Group by party, then by vote result
info = votes[name] by_party = {}
md += f"- {name} ({info['party']}): {info['vote']}\n" for name, info in votes.items():
party = info["party"]
if party not in by_party:
by_party[party] = {}
result = info["vote"]
if result not in by_party[party]:
by_party[party][result] = []
by_party[party][result].append(name)
for party in sorted(by_party):
md += f"## {party}\n\n"
for result in sorted(by_party[party]):
md += f"### {result}\n\n"
for name in sorted(by_party[party][result]):
md += f"- {name}\n"
md += "\n"
safe_name = re.sub(r'[/<>:"|?*]', "_", key)[:200] safe_name = re.sub(r'[/<>:"|?*]', "_", key)[:200]
with open(f"{dir}/{safe_name}.md", "w", encoding="utf-8") as f: with open(f"{dir}/{safe_name}.md", "w", encoding="utf-8") as f:
f.write(md) f.write(md)