#!/usr/bin/env python3 # Copyright (c) 2026 Krzysztof Rudnicki. MIT licence. """Write a synthetic photo pack for the offline end-to-end run. The real album is private and lives outside this repository, so the e2e script cannot use it -- and must not need to. This builds a pack of three invented people, one "both of them" combination and one video, which is enough to exercise every path the real one uses. python tool/e2e_pack.py --dir /tmp/pack --group 'group.abc=' """ from __future__ import annotations import argparse import base64 import json import sys from pathlib import Path from typing import Final # A 1x1 PNG, inline so that no binary file enters the repository. PIXEL: Final = base64.b64decode( "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==" ) # Not playable, and it does not have to be: nothing decodes it, the point is # that it leaves as video/mp4 rather than as a photo. CLIP: Final = b"\x00\x00\x00\x18ftypmp42fake" PEOPLE: Final = [ {"key": "p1", "triggers": ["!alfa"]}, {"key": "p2", "triggers": ["!beta"]}, {"key": "p3", "triggers": ["!gamma"]}, {"key": "p4", "triggers": ["!wideo"]}, ] COMBOS: Final = [{"key": "c1", "triggers": ["!oboje"], "all_of": ["p1", "p2"]}] TAGS: Final = { "alfa.png": ["p1"], "both.png": ["p1", "p2"], "gamma.png": ["p3"], "clip.mp4": ["p4"], } def write(directory: Path, group: str) -> None: """Write the manifest, the tags and the files themselves.""" album = directory / "media" album.mkdir(parents=True, exist_ok=True) for name in TAGS: (album / name).write_bytes(CLIP if name.endswith(".mp4") else PIXEL) manifest = {"groups": [group], "people": PEOPLE, "combos": COMBOS} (directory / "people.json").write_text(json.dumps(manifest, indent=2), encoding="utf-8") (directory / "tags.json").write_text(json.dumps(TAGS, indent=2), encoding="utf-8") def main() -> int: """Build the pack asked for on the command line.""" parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--dir", required=True, type=Path, help="where to write the pack") parser.add_argument("--group", required=True, help="the group id the pack belongs to") arguments = parser.parse_args() write(arguments.dir, arguments.group) sys.stdout.write(f"== wrote a synthetic pack to {arguments.dir}\n") return 0 if __name__ == "__main__": raise SystemExit(main())