MHRN-Space / scripts /apply_readme_alpha4.py
ThomasHeisig's picture
Sync GitHub main 4645f4137666463023fa501984a14336dd2fc666 (part 11)
31226fd verified
Raw History Blame Contribute Delete
852 Bytes
"""Insert/update the alpha.4 README section without overwriting the rest."""
from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
README = ROOT / "README.md"
BLOCK = (ROOT / "README_ALPHA4_BLOCK.md").read_text(encoding="utf-8")
START = "<!-- BRAIN5D:ALPHA4:START -->"
END = "<!-- BRAIN5D:ALPHA4:END -->"
def main() -> int:
text = README.read_text(encoding="utf-8") if README.exists() else "# MHRN\n\n"
if START in text and END in text:
before = text.split(START, 1)[0]
after = text.split(END, 1)[1]
text = before + BLOCK + after
else:
text = text.rstrip() + "\n\n" + BLOCK + "\n"
README.write_text(text, encoding="utf-8", newline="\n")
print("README alpha.4 block updated")
return 0
if __name__ == "__main__":
raise SystemExit(main())