From 3ee00e87564045defc10400304f3ec2d481770cb Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sat, 24 Aug 2024 17:14:47 +0200 Subject: Add a version with ephemeris data --- planner/planner_generator.py | 83 +++++++- planner/templates/week_on_one_page-A6-r.svg | 298 ++++++++++++++++++---------- planner/templates/week_on_one_page-A6-v.svg | 264 ++++++++++++++++-------- 3 files changed, 449 insertions(+), 196 deletions(-) (limited to 'planner') diff --git a/planner/planner_generator.py b/planner/planner_generator.py index 5d9e397..906c0fc 100755 --- a/planner/planner_generator.py +++ b/planner/planner_generator.py @@ -257,9 +257,86 @@ class BiweeklyGenerator(Generator): continue last_monday = week[0] - self.render_page(page=page, week=week) + texts = self.get_texts(week) + + self.render_page(page=page, week=week, text=texts) page += 1 + def get_texts(self, week): + return ["" for i in range(7)] + + +class EphemerisbiweeklyGenerator(BiweeklyGenerator): + """ + """ + default_template = "week_on_one_page-A6" + + def get_texts(self, week): + # we import suntime just here, because it's a third party + # library and not used elsewhere + try: + import astral + import astral.sun + import astral.moon + except ImportError: + print("Printing a planner with ephemeris requires " + "the astral library version 3.x.") + sys.exit(1) + + if not self.latitude or not self.longitude or not self.timezone: + print("Printing ephemeris requires latitude and longitude") + sys.exit(1) + + location = astral.LocationInfo( + "", + "", + self.timezone, + self.latitude, + self.longitude, + ) + local_tz = dateutil.tz.gettz(self.timezone) + + texts = [] + for day in week: + sun = astral.sun.sun(location.observer, date=day) + sunrise = sun["sunrise"].astimezone(local_tz) + noon = sun["noon"].astimezone(local_tz) + sunset = sun["sunset"].astimezone(local_tz) + moon_phase = astral.moon.phase(day) + if moon_phase < 7: + moon_icon = "●" + elif moon_phase < 14: + moon_icon = "☽" + elif moon_phase < 21: + moon_icon = "○" + else: + moon_icon = "☾" + moon_phase = round(moon_phase, 2) + try: + moon_rise = astral.moon.moonrise(location, date=day) + moon_rise = moon_rise.astimezone(local_tz).strftime("%H:%M") + except ValueError: + moon_rise = "" + try: + moon_set = astral.moon.moonset(location, date=day) + moon_set = moon_set.astimezone(local_tz).strftime("%H:%M") + except ValueError: + moon_set= "" + text = ("☼ {sunrise} — {noon} — {sunset} " + + "{moon_icon} ({moon_phase}) " + + "{moon_rise} — {moon_set} " + ).format( + sunrise=sunrise.strftime("%H:%M"), + noon=noon.strftime("%H:%M"), + sunset=sunset.strftime("%H:%M"), + moon_icon=moon_icon, + moon_phase=moon_phase, + moon_rise=moon_rise, + moon_set=moon_set, + ) + texts.append(text) + + return texts class MonthGenerator(Generator): """ @@ -304,8 +381,8 @@ class EphemerismonthGenerator(MonthGenerator): import astral.sun import astral.moon except ImportError: - print("Printing a month planner with ephemeris requires" - "the astral library.") + print("Printing a month planner with ephemeris requires " + "the astral library version 3.x.") sys.exit(1) if not self.latitude or not self.longitude or not self.timezone: diff --git a/planner/templates/week_on_one_page-A6-r.svg b/planner/templates/week_on_one_page-A6-r.svg index 51d01fa..6ad661f 100644 --- a/planner/templates/week_on_one_page-A6-r.svg +++ b/planner/templates/week_on_one_page-A6-r.svg @@ -8,7 +8,7 @@ version="1.1" id="svg5" inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" - sodipodi:docname="week_on_one_page-A6-r.svg" + sodipodi:docname="week_health-A6-r.svg" inkscape:export-filename="/home/valhalla/projects/software/pdfscripts/pdfscripts/templates/week_on_two_pages-A6-v.png" inkscape:export-xdpi="96" inkscape:export-ydpi="96" @@ -26,15 +26,15 @@ inkscape:pagecheckerboard="0" inkscape:document-units="mm" showgrid="true" - inkscape:zoom="1.0350929" - inkscape:cx="198.5329" - inkscape:cy="279.68504" - inkscape:window-width="1161" - inkscape:window-height="830" - inkscape:window-x="117" - inkscape:window-y="56" + inkscape:zoom="2.03" + inkscape:cx="186.4532" + inkscape:cy="399.01478" + inkscape:window-width="1919" + inkscape:window-height="957" + inkscape:window-x="0" + inkscape:window-y="0" inkscape:window-maximized="0" - inkscape:current-layer="layer1" + inkscape:current-layer="layer4" showguides="true" inkscape:guide-bbox="true" inkscape:showpageshadow="2" @@ -77,31 +77,9 @@ - {{ week[-1].strftime('%Y') }} - {{ week[-1].strftime('%B') }} + + + + week + + + {{ week[-1].strftime('%Y') }} + {{ week[-1].strftime('%B') }} {{ week[0].strftime('%A') }} {{ week[0].strftime('%d') }} + y="72.91803" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[0].strftime('%d') }} {{ week[1].strftime('%A') }} {{ week[1].strftime('%d') }} + y="129.61095" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[1].strftime('%d') }} {{ week[2].strftime('%A') }} {{ week[2].strftime('%d') }} + y="186.30386" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[2].strftime('%d') }} {{ week[3].strftime('%A') }} {{ week[3].strftime('%d') }} - - - + x="36.788464" + y="242.99678" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[3].strftime('%d') }} {{ week[4].strftime('%A') }} {{ week[4].strftime('%d') }} + y="299.6897" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[4].strftime('%d') }} {{ week[5].strftime('%A') }} {{ week[5].strftime('%d') }} + x="35.964436" + y="356.3826" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[5].strftime('%d') }} {{ week[6].strftime('%A') }} {{ week[6].strftime('%d') }} + y="413.07553" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[6].strftime('%d') }} + + notes + id="tspan7106-5-7-67" + x="75.059303" + y="72.973366" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.6667px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ text[0] }} + {{ text[1] }} + {{ text[2] }} + {{ text[3] }} + {{ text[4] }} + {{ text[5] }} + {{ text[6] }} diff --git a/planner/templates/week_on_one_page-A6-v.svg b/planner/templates/week_on_one_page-A6-v.svg index 9f07bd9..eb60220 100644 --- a/planner/templates/week_on_one_page-A6-v.svg +++ b/planner/templates/week_on_one_page-A6-v.svg @@ -8,7 +8,7 @@ version="1.1" id="svg5" inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" - sodipodi:docname="week_on_one_page-A6-v.svg" + sodipodi:docname="week_health-A6-v.svg" inkscape:export-filename="/home/valhalla/projects/software/pdfscripts/pdfscripts/templates/week_on_two_pages-A6-v.png" inkscape:export-xdpi="96" inkscape:export-ydpi="96" @@ -26,15 +26,15 @@ inkscape:pagecheckerboard="0" inkscape:document-units="mm" showgrid="true" - inkscape:zoom="2.2" - inkscape:cx="169.09091" - inkscape:cy="455.68182" - inkscape:window-width="1277" - inkscape:window-height="828" + inkscape:zoom="1.75" + inkscape:cx="198.28571" + inkscape:cy="404.85714" + inkscape:window-width="1919" + inkscape:window-height="950" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="0" - inkscape:current-layer="layer1" + inkscape:current-layer="layer5" showguides="true" inkscape:guide-bbox="true" inkscape:showpageshadow="2" @@ -105,17 +105,38 @@ d="M 18.89764,283.46457 H 359.05512" id="path1562-6-3" sodipodi:nodetypes="cc" /> + + + {{ week[0].strftime('%Y') }} + id="tspan7106-5-7-6-9" + x="359.05511" + y="472.44095" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:end;text-anchor:end;fill:#3f3f3f;fill-opacity:1">week + + {{ week[0].strftime('%B') }} + {{ week[0].strftime('%Y') }} {{ week[0].strftime('%A') }} {{ week[0].strftime('%d') }} + y="72.91803" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[0].strftime('%d') }} {{ week[1].strftime('%A') }} {{ week[1].strftime('%d') }} + y="129.61095" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[1].strftime('%d') }} {{ week[2].strftime('%A') }} {{ week[2].strftime('%d') }} + x="17.890833" + y="186.30386" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[2].strftime('%d') }} {{ week[3].strftime('%A') }} {{ week[3].strftime('%d') }} - - - + y="242.99678" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[3].strftime('%d') }} {{ week[4].strftime('%A') }} {{ week[4].strftime('%d') }} + x="17.848089" + y="299.6897" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[4].strftime('%d') }} {{ week[5].strftime('%A') }} {{ week[5].strftime('%d') }} + y="356.3826" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[5].strftime('%d') }} {{ week[6].strftime('%A') }} {{ week[6].strftime('%d') }} + y="413.07553" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ week[6].strftime('%d') }} + + notes + id="tspan7106-5-7-67" + x="56.161663" + y="73.845757" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.6667px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#3f3f3f;fill-opacity:1">{{ text[0] }} + {{ text[1] }} + {{ text[2] }} + {{ text[3] }} + {{ text[4] }} + {{ text[5] }} + {{ text[6] }} -- cgit v1.2.3