fix party filename crash for names containing slashes

Bündnis 90/Die Grünen contains a slash which was interpreted as a
directory separator. Sanitize party names in filenames the same way
vote topics are sanitized.

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

View file

@ -333,7 +333,8 @@ def save_readme(bios, out):
md += "| Partei | Abgeordnete |\n"
md += "|--------|------------:|\n"
for party, count in sorted(parties.items()):
md += f"| [{party}](Parteien/{party}.md) | {count} |\n"
safe_party = re.sub(r'[/<>:"|?*]', "_", party)
md += f"| [{party}](Parteien/{safe_party}.md) | {count} |\n"
md += f"\n## Verzeichnisse\n\n"
md += "- [Abgeordnete](Abgeordnete/) — Einzelprofile nach Nachname\n"
md += "- [Abstimmungen](Abstimmungen/) — Abstimmungen nach Thema\n"
@ -357,7 +358,8 @@ def save_party_index(bios, out):
if bio.job:
md += f"{bio.job}"
md += "\n"
with open(f"{dir}/{party}.md", "w", encoding="utf-8") as f:
safe_party = re.sub(r'[/<>:"|?*]', "_", party)
with open(f"{dir}/{safe_party}.md", "w", encoding="utf-8") as f:
f.write(md)