aboutsummaryrefslogtreecommitdiff
path: root/generate-gallery.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2026-02-11 12:16:47 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2026-02-11 12:21:58 +0100
commit3e0978f1da6469e33460b69b9356f55fd873f973 (patch)
tree4b860486f0d744160c350b157fed17af10212be9 /generate-gallery.py
parent3096cf2a4e22e8dd072d4495c4c61fa0fc126fcf (diff)
downloadscratch-gallery-3e0978f1da6469e33460b69b9356f55fd873f973.tar.gz
scratch-gallery-3e0978f1da6469e33460b69b9356f55fd873f973.zip
do not rebuild the html if it is newer than the scratch file
Diffstat (limited to 'generate-gallery.py')
-rwxr-xr-xgenerate-gallery.py12
1 files changed, 8 insertions, 4 deletions
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)