cpython/Doc/tools/check-epub.py
Maciej Olko 624bf52c83
gh-136155: Docs: check for EPUB fatal errors in CI (#134074)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-07-15 15:26:24 +03:00

24 lines
690 B
Python

import sys
from pathlib import Path
def main() -> int:
wrong_directory_msg = "Must run this script from the repo root"
if not Path("Doc").exists() or not Path("Doc").is_dir():
raise RuntimeError(wrong_directory_msg)
with Path("Doc/epubcheck.txt").open(encoding="UTF-8") as f:
messages = [message.split(" - ") for message in f.read().splitlines()]
fatal_errors = [message for message in messages if message[0] == "FATAL"]
if fatal_errors:
print("\nError: must not contain fatal errors:\n")
for error in fatal_errors:
print(" - ".join(error))
return len(fatal_errors)
if __name__ == "__main__":
sys.exit(main())