44 lines
2.4 KiB
Python
44 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
||
"""gallery.py — build screens/README.md: every screenshot, phone and computer side by side, HU and EN (Part E).
|
||
|
||
Files named `<prefix>-<phone|desktop>-<hu|en>.png` (tools/shot.py) are grouped by prefix into one row each; anything
|
||
else (console captures, bind.py's numbered shots) is listed under its folder. Relative links only, so the operator can
|
||
look without a box. Before writing, every image is listed with its size so a reviewer can spot one that was never
|
||
checked for a secret (rule 4: a screenshot that shows a secret is deleted, not committed).
|
||
usage: gallery.py <screens dir>
|
||
"""
|
||
import os, re, sys
|
||
from collections import OrderedDict
|
||
|
||
root = sys.argv[1]
|
||
pat = re.compile(r"^(?P<p>.+)-(?P<s>phone|desktop)-(?P<l>hu|en)\.png$")
|
||
out = ["# Rehearsal 2026-10-20 — every screen the household met", "",
|
||
"Phone = 390×844, computer = 1366×768 (Chromium 155 + Playwright 1.52.0 in a throwaway container; see "
|
||
"`../A4-browser/`). Hungarian and English browser languages. Codes, passwords and links are blacked out or "
|
||
"never shown. Console captures are QEMU screendumps of the VM's monitor.", ""]
|
||
for folder in sorted(d for d in os.listdir(root) if os.path.isdir(os.path.join(root, d))):
|
||
files = sorted(f for f in os.listdir(os.path.join(root, folder)) if f.endswith(".png"))
|
||
if not files:
|
||
continue
|
||
out += [f"## {folder}", ""]
|
||
groups, rest = OrderedDict(), []
|
||
for f in files:
|
||
m = pat.match(f)
|
||
if m:
|
||
groups.setdefault(m["p"], {})[(m["s"], m["l"])] = f
|
||
else:
|
||
rest.append(f)
|
||
if groups:
|
||
out += ["| screen | phone HU | phone EN | computer HU | computer EN |", "|---|---|---|---|---|"]
|
||
for p, g in groups.items():
|
||
cells = []
|
||
for k in (("phone", "hu"), ("phone", "en"), ("desktop", "hu"), ("desktop", "en")):
|
||
cells.append(f'<img src="{folder}/{g[k]}" width="{140 if k[0] == "phone" else 260}">' if k in g else "—")
|
||
out.append(f"| `{p}` | " + " | ".join(cells) + " |")
|
||
out.append("")
|
||
for f in rest:
|
||
out += [f"**{f}**", "", f'<img src="{folder}/{f}" width="520">', ""]
|
||
open(os.path.join(root, "README.md"), "w", encoding="utf-8").write("\n".join(out) + "\n")
|
||
print("gallery:", sum(len([f for f in os.listdir(os.path.join(root, d)) if f.endswith('.png')])
|
||
for d in os.listdir(root) if os.path.isdir(os.path.join(root, d))), "images")
|