Whittaker's History (1910), reviewed › The review's files › sim/whittaker/fold31/
fold_lib.py
"""Edits for folding the thirty-first reviewer's findings (task T7) into the Whittaker pages' sources. Author seat, 25 November 2026.
Each edit names a file, a phrase that picks out exactly one line, and a change inside that line. It stops if the line is not unique or the old text is absent."""
import os
ROOT = '/home/doug/aetherscience.org/aspden-investigation/papers'
LOG = []
def rep(rel, anchor, old, new, why):
p = os.path.join(ROOT, rel)
lines = open(p, encoding='utf-8').read().split('\n')
hits = [i for i, l in enumerate(lines) if anchor in l]
if len(hits) != 1:
raise SystemExit(f"{rel}: anchor {anchor!r} found on {len(hits)} lines")
i = hits[0]
if old not in lines[i]:
raise SystemExit(f"{rel}:{i+1}: {old!r} not in the line")
if lines[i].count(old) != 1:
raise SystemExit(f"{rel}:{i+1}: {old!r} more than once in the line")
lines[i] = lines[i].replace(old, new)
open(p, 'w', encoding='utf-8').write('\n'.join(lines))
LOG.append(f"{rel}:{i+1} | {why}")