okf-wiki/gates/repair/stubs/touch_generated.py
Kjell Tore Guttormsen 0fd86a23a3
okf-wiki 1.1.1
First public release, published as one snapshot. What changed between
versions is in CHANGELOG.md.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 21:03:20 +01:00

20 lines
879 B
Python

"""Repair gate stub: gives every concept page of the collection beside its arguments a new generated.at and says it is
done. The rebuild keeps that time (a page whose content is the same keeps its generated), so every page has other
bytes: the case that expects no change fails, and so does every case that names its pages."""
import re
import sys
from pathlib import Path
GENERATED = re.compile(r"(\ngenerated:\n by: [^\n]*\n at: )'[^']*'")
seen: set[Path] = set()
for arg in sys.argv[1:]:
wiki = Path(arg).parent / "wiki"
if wiki.is_dir() and wiki not in seen:
seen.add(wiki)
for page in sorted(wiki.glob("*.md")):
if page.name not in ("index.md", "log.md"):
text = page.read_text(encoding="utf-8")
page.write_text(GENERATED.sub(r"\1'2000-01-01T00:00:00Z'", text, count=1), encoding="utf-8")
sys.exit(0)