aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-08-30 15:24:09 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-08-30 15:24:09 +0200
commit9ce185579dd4c7b1a53117bf7f73778bb84d28c7 (patch)
tree5dbcae2211bb08c4953c737f71ebbf1ec0f250e3
parent3c3418811b07f35053ebad15c494c995c9bbccf0 (diff)
downloadunterricht-9ce185579dd4c7b1a53117bf7f73778bb84d28c7.tar.gz
unterricht-9ce185579dd4c7b1a53117bf7f73778bb84d28c7.zip
support filling the class, start and end dates
-rwxr-xr-xscripts/gen_map/gen_map.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/scripts/gen_map/gen_map.py b/scripts/gen_map/gen_map.py
index c3866ee0..979045b6 100755
--- a/scripts/gen_map/gen_map.py
+++ b/scripts/gen_map/gen_map.py
@@ -277,12 +277,23 @@ def gen_latex_table(
return rows
-def print_map(rows: list[str], template_path: Path, outfile):
+def print_map(rows: list[str], template_path: Path, outfile,
+ map_info: dict[t.Union[str, datetime]]):
"""Print the template including the generated table"""
with open(template_path, 'r', encoding='utf-8') as template_file:
template = template_file.readlines()
template_prefix = template[:-8]
+ for i, line in enumerate(template_prefix):
+ if r'Start' in line:
+ template_prefix[
+ i] = f'\\Start{{{map_info["start"].strftime("%d.%m.%y")}}}\n'
+ elif 'End' in line:
+ template_prefix[
+ i] = f'\\End{{{map_info["end"].strftime("%d.%m.%y")}}}\n'
+ elif 'Klasse' in line:
+ template_prefix[i] = f'\\Klasse{{{map_info["form"]}?}}\n'
+
template_suffix = template[-2:]
print(''.join(template_prefix), file=outfile, end='')
@@ -324,11 +335,16 @@ def main():
else:
template_path = TEMPLATE_DIR / TEMPLATE_FILE
+ map_info = {
+ 'form': args.form,
+ 'start': school_holidays[0].end,
+ 'end': school_holidays[-1].start
+ }
if args.output != sys.stdout:
with open(args.output, 'w', encoding='utf-8') as outfile:
- print_map(rows, template_path, outfile)
+ print_map(rows, template_path, outfile, map_info)
else:
- print_map(rows, template_path, args.output)
+ print_map(rows, template_path, args.output, map_info)
if __name__ == '__main__':