Answer principles round 1: 0 🔴, 2 🟡 (0 misread); move say beside Effects and drop a clock comparison from the black-box test

This commit is contained in:
2026-10-28 18:40:24 +01:00
parent 4d40cc81bc
commit 6e171fe2c0
12 changed files with 24 additions and 37 deletions
+8 -1
View File
@@ -37,7 +37,7 @@ class Effects:
execv: typing.Callable[[str, list[str]], None]
git: Git
input: typing.Callable[[str], str]
# A time of day in the machine's zone, as `2026-10-28 11:46:01`.
# A time of day in the machine's zone, as `2026-10-28 11:46:01`. The spelling, and local time over UTC, is lilleman's call of 2026-10-28.
local_time: typing.Callable[[float], str]
# The machine's memory; None where it cannot be read.
memory: typing.Callable[[], Memory | None]
@@ -88,3 +88,10 @@ def run_python(args: list[str], cwd: str, timeout: float) -> subprocess.Complete
return subprocess.CompletedProcess(command, 1, "", f"could not start: {failure}")
except subprocess.TimeoutExpired:
return subprocess.CompletedProcess(command, 1, "", f"stopped after {timeout} s")
def say(text: str, effects: Effects, *, stdout: bool = False) -> None:
"""Prints text on stderr, or on stdout where stdout, opening its first line with the machine's local time, so the human sees when it happened. Blank lines before the text stay blank, and only its first line gets the time."""
body = text.lstrip("\n")
blanks = text[: len(text) - len(body)]
print(f"{blanks}{effects.local_time(effects.now())} {body}", file=sys.stdout if stdout else sys.stderr, flush=True)