Answer the architect: fail a judge that answers without interrupting, read every checkout file through one function

This commit is contained in:
2026-10-03 00:39:20 +02:00
parent 6340e5a993
commit 160b1dae5f
6 changed files with 32 additions and 26 deletions
+10
View File
@@ -27,3 +27,13 @@ def worktrees(root: str, effects: Effects) -> list[str]:
def project_key(root: str, code: pathlib.Path) -> str:
return root.removeprefix(f"{code}/").lstrip("/")
def read_checkout_file(root: str, name: str, consequence: str) -> str | Stop:
try:
return pathlib.Path(root, name).read_text(encoding="utf-8")
except OSError as failure:
return Stop(1, f"{name} in {root}: {failure.strerror} - {consequence}.")
except UnicodeDecodeError as failure:
line = failure.object.count(b"\n", 0, failure.start) + 1
return Stop(1, f"{name} is not UTF-8 on line {line} - {consequence}.")