From 55a7966d493e9972e07a60cc7ecbfba9a93a2eee Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Tue, 2 Nov 2021 11:42:46 +0100 Subject: Weekly planner generator: quick hardcoded script step 1: generate svgs --- templates/week_on_two_pages-A6-r.svg | 201 +++++++++++++++++++++++++++++++++ templates/week_on_two_pages-A6-v.svg | 212 +++++++++++++++++++++++++++++++++++ weekly_planner_generator.py | 48 ++++++++ 3 files changed, 461 insertions(+) create mode 100644 templates/week_on_two_pages-A6-r.svg create mode 100644 templates/week_on_two_pages-A6-v.svg create mode 100755 weekly_planner_generator.py diff --git a/templates/week_on_two_pages-A6-r.svg b/templates/week_on_two_pages-A6-r.svg new file mode 100644 index 0000000..58fdb81 --- /dev/null +++ b/templates/week_on_two_pages-A6-r.svg @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + {{ week[-1].strftime('%Y') }} + {{ week[-1].strftime('%B') }} + {{ week[4].strftime('%A') }} + {{ week[4].strftime('%d') }} + {{ week[5].strftime('%A') }} + {{ week[5].strftime('%d') }} + {{ week[6].strftime('%A') }} + {{ week[6].strftime('%d') }} + notes + + diff --git a/templates/week_on_two_pages-A6-v.svg b/templates/week_on_two_pages-A6-v.svg new file mode 100644 index 0000000..9e84b91 --- /dev/null +++ b/templates/week_on_two_pages-A6-v.svg @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + {{ week[0].strftime('%Y') }} + {{ week[0].strftime('%B') }} + {{ week[0].strftime('%A') }} + {{ week[0].strftime('%d') }} + {{ week[1].strftime('%A') }} + {{ week[1].strftime('%d') }} + {{ week[2].strftime('%A') }} + {{ week[2].strftime('%d') }} + {{ week[3].strftime('%A') }} + {{ week[3].strftime('%d') }} + + diff --git a/weekly_planner_generator.py b/weekly_planner_generator.py new file mode 100755 index 0000000..d5bd90c --- /dev/null +++ b/weekly_planner_generator.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 + +import argparse +import calendar +import os + +import jinja2 + + +def main(): + env = jinja2.Environment() + loader = jinja2.FileSystemLoader('templates') + template_verso = loader.load(env, 'week_on_two_pages-A6-v.svg') + template_recto = loader.load(env, 'week_on_two_pages-A6-r.svg') + + os.makedirs("build", exist_ok=True) + + year = 2022 + + cal = calendar.Calendar() + weeks = sum([r[0] for r in cal.yeardatescalendar(2022, width=1)], []) + + last_monday = None + page = 1 + for week in weeks: + # yeardatescalendar will have the same week twice at the margin + # of a month, but we want to skip one of those + if week[0] == last_monday: + continue + last_monday = week[0] + + with open("build/week_on_two_pages-A6-{year}-{page:02}.svg".format( + year=year, + page=page, + ), 'w') as fp: + fp.write(template_verso.render(week=week)) + page += 1 + + with open("build/week_on_two_pages-A6-{year}-{page:02}.svg".format( + year=year, + page=page, + ), 'w') as fp: + fp.write(template_recto.render(week=week)) + page += 1 + + +if __name__ == '__main__': + main() -- cgit v1.2.3