chore: QA-Skripte nach tools/qa übernommen
Die Werkzeuge der QA-Runden lagen nur im ignorierten .qa/: CLI-Matrix (89 Fälle), Fixture-Generator, unabhängiger Markdown-Validator, Wortvergleich gegen Datenverlust, Pandoc-Prüfung (HTML, EPUB, PDF). Jetzt versioniert in tools/qa/ mit README und requirements.txt; erzeugte Daten landen weiterhin in .qa/. Pfade auf die neue Lage angepasst (Repo-Wurzel über parents[2], aufrufender Python-Interpreter). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
57d485baa3
commit
01f60a41c4
1 changed files with 1210 additions and 2 deletions
36
tools/qa/pyblocks.py
Executable file
36
tools/qa/pyblocks.py
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
"""Listet Python-Codeblöcke mit Einrückungsfehlern in Markdown-Dateien (mit Inhalt, zum Vergleich mit der Quelle).
|
||||
|
||||
Aufruf: python tools/qa/pyblocks.py AUSGABE/chapters/*.md
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def main() -> None:
|
||||
for path in sys.argv[1:]:
|
||||
with open(path, encoding="utf-8") as fh:
|
||||
lines = fh.read().split("\n")
|
||||
i = 0
|
||||
while i < len(lines):
|
||||
m = re.match(r"^(`{3,})python\s*$", lines[i])
|
||||
if m:
|
||||
j = i + 1
|
||||
while j < len(lines) and not lines[j].startswith(m.group(1)):
|
||||
j += 1
|
||||
try:
|
||||
ast.parse("\n".join(lines[i + 1:j]))
|
||||
except IndentationError as exc:
|
||||
print(f"== {path}:{i + 1} {exc.msg} (Blockzeile {exc.lineno})")
|
||||
print("\n".join(f"{k + 1:3}|{line}" for k, line in enumerate(lines[i + 1:j])))
|
||||
except SyntaxError:
|
||||
pass # fragments and program output are no indentation defects
|
||||
i = j
|
||||
i += 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in a new issue