Files
H2W-Public-Legal/scripts/render-templates.py
Your NameandClaude Sonnet 5 d32c73d409 Publikáció-előkészítés: tervezet-jelölések eltávolítása, adatok kitöltése, egyetlen forrású ismétlődő adatok
A négy H2W-Ticketing jogi dokumentumból eltűnt minden tervezet-jelleg:
- belsős "Megjegyzés a tervezethez" és "[Tisztázandó]" blokkok törölve
- minden [szögletes zárójeles] helyőrző valós adattal kitöltve
- elvi hibák javítva: az adatfeldolgozói melléklet aláírásmezővel és a
  partner cégadatainak kitöltendő blokkjával rendelkező kétoldalú
  szerződés volt, holott publikus HTML-ként szolgáljuk ki; a megszűnt
  EU ODR-platform mint jogorvoslati fórum törölve; a DPA
  al-adatfeldolgozó-táblájában szereplő Google Analytics javítva a
  ténylegesen használt Umamira
- a HBus-12/HBus-16/HRF-A-7 YouTrackben eldöntött, de eddig meg nem írt
  klauzulák bekerültek: SLA-jóváírás, AI-felelősségkizárás, kvóta- és
  túlfutási szabályok, adatbázis-kötbér

Az ismétlődő adatok (szolgáltató azonosítója, tárhelyszolgáltató,
al-adatfeldolgozók) mostantól egyetlen helyen (_data.json) szerkeszthetők:
a H2W-Ticketing/*.md fájlok a _templates/*.md sablonokból generálódnak a
scripts/render-templates.py futtatásával. A generált fájlok tartalma
változatlan marad a build-manifest.py és a fogyasztó szinkron-szkriptek
számára — content_hash/version továbbra is a végleges, feloldott
szöveget hasheli.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-08-05 21:29:50 +02:00

82 lines
3.1 KiB
Python

#!/usr/bin/env python3
"""Resolves each project's _templates/*.md against its _data.json and overwrites
the tracked *.md files with the result.
Why this exists: the legal documents repeat the same provider identity, hosting
entity, and sub-processor names/countries across several files — each document
phrases its surrounding table differently, so it's the *values*, not whole
blocks, that repeat. Before this script, changing e.g. the company address
meant editing every document by hand and risking them drifting apart.
The templates are the edit source; the tracked *.md files are a build output,
exactly like dist/legal-manifest.json is a build output of build-manifest.py.
Both are committed to git, so build-manifest.py's content_hash/version (which
hash the tracked *.md, not the template) keep meaning exactly what they did
before this script existed — and downstream consumers that read the tracked
H2W-Ticketing/*.md directly are unaffected, since they still see fully
resolved text, never a placeholder.
Placeholder syntax: {{ dotted.path }}, resolved against _data.json. Deliberately
NOT used for numeric periods (30 nap, 8 nap, 99%, ...) that happen to repeat —
those repeat by coincidence of value, not by shared identity, and collapsing
them would risk an edit to one clause silently changing an unrelated one.
Usage:
python3 scripts/render-templates.py # resolve and overwrite
python3 scripts/render-templates.py --check # exit 1 on drift, write nothing
"""
import json
import re
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
TOKEN_RE = re.compile(r"\{\{\s*([\w.]+)\s*\}\}")
def resolve_token(data: dict, dotted_path: str) -> str:
value = data
for part in dotted_path.split("."):
value = value[part]
return value
def render(template: str, data: dict) -> str:
return TOKEN_RE.sub(lambda m: resolve_token(data, m.group(1)), template)
def main() -> None:
check_only = "--check" in sys.argv
drift = False
for project_dir in sorted(REPO_ROOT.iterdir()):
templates_dir = project_dir / "_templates"
if not templates_dir.is_dir():
continue
data_path = project_dir / "_data.json"
data = json.loads(data_path.read_text(encoding="utf-8"))
for template_path in sorted(templates_dir.glob("*.md")):
target_path = project_dir / template_path.name
resolved = render(template_path.read_text(encoding="utf-8"), data)
if check_only:
current = target_path.read_text(encoding="utf-8") if target_path.exists() else None
if current != resolved:
print(f"ELTÉRÉS: {target_path.relative_to(REPO_ROOT)}")
drift = True
continue
target_path.write_text(resolved, encoding="utf-8")
print(f"Feloldva: {target_path.relative_to(REPO_ROOT)}")
if check_only and drift:
print("A sablonokból generált tartalom eltér a commitolt fájloktól — futtasd: python3 scripts/render-templates.py")
sys.exit(1)
if __name__ == "__main__":
main()