From 046d9c920ac2439d02a18517083449f0e99f9e9d Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 19 Jan 2026 18:10:31 +0100 Subject: add and support HTML templates --- spgen.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'spgen.py') diff --git a/spgen.py b/spgen.py index 42ddfed..a72f440 100755 --- a/spgen.py +++ b/spgen.py @@ -8,6 +8,10 @@ import sys class SPTemplate(Template): + """Seating plan template + + %% is used as delimiter because the most templates are written in LaTeX. + """ delimiter = '%%' @@ -15,11 +19,22 @@ def print_sp_template(template: SPTemplate, duration: str, names: list[str], seats: list[int]): """Print the template including our name definitions""" defs = [] - for name in names: - seat = seats.pop() + seating = {i: '' for i in range(1, 33)} + for i, name in enumerate(names): + seat = seats[i] + seating[seat] = name defs.append(rf'\csdef{{name{seat}}}{{{name}}}') + defs.append(rf'\csdef{{duration}}{{{duration}}}') - print(template.substitute({'defs': '\n'.join(defs)})) + + subs = { + 'defs': '\n'.join(defs) + } | { + f'name{seat}': name + for seat, name in seating.items() + } + + print(template.substitute(subs)) def main(): -- cgit v1.2.3