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:
parent
e2bc067c30
commit
8470b4ba98
1 changed files with 17 additions and 3 deletions
20
crawler.py
20
crawler.py
|
|
@ -310,9 +310,23 @@ def save_votes(bios, out):
|
|||
# Generate one markdown file per vote topic
|
||||
for key, votes in sorted(all_votes.items()):
|
||||
md = f"# {key}\n\n"
|
||||
for name in sorted(votes, key=lambda n: votes[n]["party"]):
|
||||
info = votes[name]
|
||||
md += f"- {name} ({info['party']}): {info['vote']}\n"
|
||||
# Group by party, then by vote result
|
||||
by_party = {}
|
||||
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]
|
||||
with open(f"{dir}/{safe_name}.md", "w", encoding="utf-8") as f:
|
||||
f.write(md)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue