Add blanko build target, fix preamble duplication, update event config and margins
- Add --blanko flag to generate_cards.py for blank cards (no CSV needed), 2-up layout - Fix preamble duplication bug affecting both blanko and multi-participant personalized builds - Add make build-blanko target; default make now builds personalized + blanko - Reduce page margins from 0.8cm to 0.4cm for Kyocera P6026 - Widen tikzpicture columns (6.9→7.2cm) and tabular columns (6.6→7.0cm) to fill page width - Update event.yml for BRM400 Bonn–Lüttich–Bastogne–Bonn, 9. Mai 2026, with 6 controls Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+37
-2
@@ -2,6 +2,7 @@
|
||||
"""
|
||||
Generate personalized brevet cards from CSV and event config.
|
||||
"""
|
||||
import argparse
|
||||
import csv
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -92,7 +93,23 @@ def generate_card_from_template(template, data):
|
||||
return card
|
||||
|
||||
|
||||
def generate_blanko_card(template):
|
||||
"""Generate a blank card with empty participant fields."""
|
||||
card = template.replace('{{NAME}}', '')
|
||||
card = card.replace('{{STREET}}', '')
|
||||
card = card.replace('{{PLZ_ORT}}', '')
|
||||
card = card.replace('{{LAND}}', '')
|
||||
card = card.replace('{{MEDAILLE}}', '')
|
||||
card = card.replace('{{STARTNR}}', '')
|
||||
return card
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--blanko', action='store_true',
|
||||
help='Generate blank card without participant data')
|
||||
args = parser.parse_args()
|
||||
|
||||
csv_file = Path("export_brevetcard.csv")
|
||||
template_file = Path("brevetkarte-template.tex")
|
||||
backside_template_file = Path("brevetkarte-rueckseite-template.tex")
|
||||
@@ -112,6 +129,24 @@ def main():
|
||||
template = template_file.read_text(encoding='utf-8')
|
||||
template = apply_event_placeholders(template, event_config)
|
||||
|
||||
# Split preamble from body so \begin{document} appears only once per file
|
||||
marker = '\\begin{document}'
|
||||
doc_idx = template.find(marker)
|
||||
preamble = template[:doc_idx + len(marker)]
|
||||
body = template[doc_idx + len(marker):]
|
||||
|
||||
if args.blanko:
|
||||
blanko_output_file = Path("brevetkarte-blanko.tex")
|
||||
blanko_body = generate_blanko_card(body)
|
||||
blanko_output = preamble + blanko_body + "\n\\vspace{0.8cm}\n\n" + blanko_body + "\n\\end{document}\n"
|
||||
blanko_output_file.write_text(blanko_output, encoding='utf-8')
|
||||
print(f"Generated {blanko_output_file}")
|
||||
backside_template = backside_template_file.read_text(encoding='utf-8')
|
||||
backside_output = generate_backside(backside_template, event_config)
|
||||
backside_output_file.write_text(backside_output, encoding='utf-8')
|
||||
print(f"Generated {backside_output_file}")
|
||||
return
|
||||
|
||||
print(f"Reading participant data from {csv_file}...")
|
||||
participants = []
|
||||
with open(csv_file, 'r', encoding='utf-8-sig') as f:
|
||||
@@ -129,10 +164,10 @@ def main():
|
||||
# Generate personalized front side
|
||||
cards = []
|
||||
for participant in participants:
|
||||
card = generate_card_from_template(template, participant)
|
||||
card = generate_card_from_template(body, participant)
|
||||
cards.append(card)
|
||||
|
||||
document_parts = []
|
||||
document_parts = [preamble]
|
||||
for i, card in enumerate(cards):
|
||||
document_parts.append(card)
|
||||
if i % 2 == 0 and i < len(cards) - 1:
|
||||
|
||||
Reference in New Issue
Block a user