From f9345021f03ee7925a30c56cbb57b68d735ba213 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Mon, 2 Sep 2024 15:10:26 +0200 Subject: Add support for arbitrary sizes --- planner/planner_generator.py | 19 +++-- "planner/templates/cover-95\303\227186-r.svg" | 97 ++++++++++++++++++++++ "planner/templates/daily-95\303\227186-r.svg" | 113 ++++++++++++++++++++++++++ "planner/templates/daily-95\303\227186-v.svg" | 113 ++++++++++++++++++++++++++ 4 files changed, 337 insertions(+), 5 deletions(-) create mode 100644 "planner/templates/cover-95\303\227186-r.svg" create mode 100644 "planner/templates/daily-95\303\227186-r.svg" create mode 100644 "planner/templates/daily-95\303\227186-v.svg" (limited to 'planner') diff --git a/planner/planner_generator.py b/planner/planner_generator.py index 906c0fc..2da3133 100755 --- a/planner/planner_generator.py +++ b/planner/planner_generator.py @@ -6,6 +6,7 @@ import datetime import locale import logging import os +import re import shutil import subprocess import sys @@ -87,6 +88,8 @@ class Generator: return "a5" if "A4" in template: return "a4" + if "×" in template: + return re.findall(r"\d+×\d+", template)[0] return "a6" def _get_cover_name(self, cover_template): @@ -163,14 +166,20 @@ class Generator: def join_pages(self): pdf_pages = self.get_pdf_pages() - try: - subprocess.run([ + command = [ "pdfjam", "--outfile", self.out_file, "--scale", "1", - "--paper", "{}paper".format(self.paper_size), - *pdf_pages - ]) + ] + if "×" in self.paper_size: + x, y = self.paper_size.split("×") + size = "{" + x + "mm," + y + "mm}" + command.extend(["--papersize", size]) + else: + command.extend(["--paper", "{}paper".format(self.paper_size)]) + command.extend(pdf_pages) + try: + subprocess.run(command) except FileNotFoundError: logging.warning("pdfjam is not installed") logging.warning("you will have to join the pdf pages yourself") diff --git "a/planner/templates/cover-95\303\227186-r.svg" "b/planner/templates/cover-95\303\227186-r.svg" new file mode 100644 index 0000000..615745b --- /dev/null +++ "b/planner/templates/cover-95\303\227186-r.svg" @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + {{ year }} + + diff --git "a/planner/templates/daily-95\303\227186-r.svg" "b/planner/templates/daily-95\303\227186-r.svg" new file mode 100644 index 0000000..660d31f --- /dev/null +++ "b/planner/templates/daily-95\303\227186-r.svg" @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + {{ day.strftime("%A") }} + {{ day.strftime("%d %B %Y").strip('0') }} + + diff --git "a/planner/templates/daily-95\303\227186-v.svg" "b/planner/templates/daily-95\303\227186-v.svg" new file mode 100644 index 0000000..4400c4e --- /dev/null +++ "b/planner/templates/daily-95\303\227186-v.svg" @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + {{ day.strftime("%d %B %Y").strip('0') }} + {{ day.strftime("%A") }} + + -- cgit v1.2.3