fix: download pictures from include scripts

This commit is contained in:
Matthias Jung
2026-01-24 21:56:33 +01:00
parent 99e97ee3c6
commit f5be12555c
+11 -3
View File
@@ -1,5 +1,6 @@
import json import json
import random import random
import re
import shutil import shutil
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
@@ -129,8 +130,7 @@ class Build:
page_template = self.env.get_template("html/page.html") page_template = self.env.get_template("html/page.html")
return page_template.render(content=content, course_wrapper=course_wrapper, sidebar=sidebar) return page_template.render(content=content, course_wrapper=course_wrapper, sidebar=sidebar)
def __picture_handler(self, id): def __copy_picture(self, id):
self.config.p_build_pictures.mkdir(parents=True, exist_ok=True)
file = f"{id}.svg" file = f"{id}.svg"
try: try:
shutil.copyfile(self.config.p_data_pictures / file, self.config.p_build_pictures / file) shutil.copyfile(self.config.p_data_pictures / file, self.config.p_build_pictures / file)
@@ -141,6 +141,10 @@ class Build:
except FileNotFoundError: except FileNotFoundError:
tqdm.write(f"\033[31mPicture #{id} not found\033[0m") tqdm.write(f"\033[31mPicture #{id} not found\033[0m")
def __picture_handler(self, id):
self.config.p_build_pictures.mkdir(parents=True, exist_ok=True)
return self.__copy_picture(id)
def __photo_handler(self, id): def __photo_handler(self, id):
self.config.p_build_photos.mkdir(parents=True, exist_ok=True) self.config.p_build_photos.mkdir(parents=True, exist_ok=True)
file = f"{id}.jpg" file = f"{id}.jpg"
@@ -177,7 +181,11 @@ class Build:
def __include_handler(self, include): def __include_handler(self, include):
with (self.config.p_data / "includes.json").open() as file: with (self.config.p_data / "includes.json").open() as file:
includes = json.load(file) includes = json.load(file)
return includes.get(include) code = includes.get(include)
svg_list = re.findall(r"(\d+)\.svg", code or "")
for id in svg_list:
self.__copy_picture(id)
return code
# cached # cached
def __build_section( def __build_section(