From 3e0978f1da6469e33460b69b9356f55fd873f973 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 11 Feb 2026 12:16:47 +0100 Subject: do not rebuild the html if it is newer than the scratch file --- generate-gallery.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'generate-gallery.py') diff --git a/generate-gallery.py b/generate-gallery.py index 3600cb7..6fcdfa7 100755 --- a/generate-gallery.py +++ b/generate-gallery.py @@ -128,9 +128,14 @@ def package_projects(_indir: str, _outdir: str, all_projects: dict): shutil.copyfile(infile, projectoutdir / project['Datei']) continue + project['Datei'] = 'demo_output.html' + + # Skip packaging if the result is newer than the input + if os.path.getmtime(infile) < os.path.getmtime(projectoutdir / 'demo_output.html'): + continue + cmd = _cmd.format(infile='..' / infile, outdir='..' / projectoutdir) subprocess.run(cmd, cwd='turbowarp-packager-cli', check=True, shell=True) - project['Datei'] = 'demo_output.html' def main(): @@ -147,17 +152,16 @@ def main(): help='output location of the generated HTML code') args = parser.parse_args() - env = Environment(loader=FileSystemLoader("templates"), autoescape=select_autoescape()) + env = Environment(loader=FileSystemLoader('templates'), autoescape=select_autoescape()) projects = load_projects(args.projects_dir) - # print(projects, file=sys.stderr) prepare_outputdir(args.output_dir, projects) if not args.no_packaging: package_projects(args.projects_dir, args.output_dir, projects) - template = env.get_template("index.html") + template = env.get_template('index.html') with open(pathlib.Path(args.output_dir) / 'index.html', 'w', encoding='utf-8') as outfile: print(template.render(projects=projects, **args.__dict__), file=outfile) -- cgit v1.2.3