#!/usr/bin/env python3 """job #2485 -- repair of return #1180's two flagged .out files. The two files are stdout+stderr captures of `ladder2483.py` run at x = 19 and x = 23. Each carries one line that names a machine-specific Windows scratchpad path in the captured numpy RuntimeWarning. This script rewrites *only* that path, to the repository-relative name of the script as the published recipe invokes it (`python ladder2483.py 19 12` from the directory holding it), and asserts that every other byte of the two files is unchanged. It writes the corrected copies as `ladder2483-19.out` / `ladder2483-23.out` in the output directory and records the per-file line diff for the return. Run: python3 fix_paths2485.py holds ladder2483-19.orig.out / ladder2483-23.orig.out (the bytes as served, SHA-256 0fbd1189... / 9161f990...) plus ladder2483-19.fresh.out / -23.fresh.out, the output of re-running the served script in a fresh directory (control, see REPORT.md). """ import re import sys import pathlib # The one offending path, as it appears verbatim in both served .out files. ABS = re.compile(rb"C:\\Users\\nate\\AppData\\Local\\Temp\\claude\\c--Projects-SolveAtHome" rb"\\[0-9a-f-]{36}\\scratchpad\\job2483\\ladder2483\.py") REL = b"ladder2483.py" def main() -> int: src = pathlib.Path(sys.argv[1]) out = pathlib.Path(sys.argv[2]) out.mkdir(parents=True, exist_ok=True) ok = True for x in (19, 23): original = (src / f"ladder2483-{x}.orig.out").read_bytes() fixed, n = ABS.subn(REL, original) (out / f"ladder2483-{x}.out").write_bytes(fixed) changed = [i for i, (a, b) in enumerate( zip(original.splitlines(), fixed.splitlines()), 1) if a != b] # every other line byte-identical, exactly one changed line, none added or removed same_lines = original.splitlines()[:changed[0] - 1] == \ fixed.splitlines()[:changed[0] - 1] and \ original.splitlines()[changed[0]:] == fixed.splitlines()[changed[0]:] residual = ABS.findall(fixed) print(f"x={x}: substitutions={n} changed_lines={changed} " f"other_lines_identical={same_lines} residual_abs_paths={len(residual)} " f"bytes {len(original)} -> {len(fixed)}") print(f" before: {original.splitlines()[changed[0]-1].decode()}") print(f" after : {fixed.splitlines()[changed[0]-1].decode()}") ok = ok and n == 1 and same_lines and not residual print("ALL_OK" if ok else "FAILED") return 0 if ok else 1 if __name__ == "__main__": sys.exit(main())