Hiányzó adat („-”) sora kimarad a dokumentumokból; DPA: az Adatkezelő adatvédelmi kapcsolattartója a tulajdonos (ügyvezető)
Build legal manifest / build-manifest (push) Successful in 14s
Build legal manifest / build-manifest (push) Successful in 14s
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e03af86566
commit
3f63af4c89
@@ -16,7 +16,13 @@ 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
|
||||
Placeholder syntax: {{ dotted.path }}, resolved against _data.json.
|
||||
|
||||
Missing data: a value of "-", "—" or "" in _data.json means "nincs ilyen adat" (pl. egyéni
|
||||
vállalkozónak nincs cégjegyzékszáma). Such a value is never printed:
|
||||
- a markdown table row ("| ... |") containing such a token is dropped entirely;
|
||||
- an optional inline segment [[ ... ]] containing such a token is dropped (otherwise only
|
||||
its brackets are removed), e.g. "[[, nyilvántartási szám: {{ provider.registration_number }}]]". 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.
|
||||
@@ -42,8 +48,24 @@ def resolve_token(data: dict, dotted_path: str) -> str:
|
||||
return value
|
||||
|
||||
|
||||
MISSING_VALUES = {"", "-", "—"}
|
||||
OPTIONAL_RE = re.compile(r"\[\[(.*?)\]\]", re.DOTALL)
|
||||
|
||||
|
||||
def _has_missing(text: str, data: dict) -> bool:
|
||||
return any(str(resolve_token(data, m.group(1))).strip() in MISSING_VALUES for m in TOKEN_RE.finditer(text))
|
||||
|
||||
|
||||
def render(template: str, data: dict) -> str:
|
||||
return TOKEN_RE.sub(lambda m: resolve_token(data, m.group(1)), template)
|
||||
# 1) opcionális szakaszok: hiányzó adattal együtt kimaradnak
|
||||
template = OPTIONAL_RE.sub(lambda m: "" if _has_missing(m.group(1), data) else m.group(1), template)
|
||||
# 2) táblázatsor hiányzó adattal: az egész sor kimarad
|
||||
lines = [
|
||||
line
|
||||
for line in template.split("\n")
|
||||
if not (line.lstrip().startswith("|") and _has_missing(line, data))
|
||||
]
|
||||
return TOKEN_RE.sub(lambda m: resolve_token(data, m.group(1)), "\n".join(lines))
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
Reference in New Issue
Block a user