import io, re, difflib, hashlib def read(p): return io.open(p, encoding="utf-8", newline="").read().replace("\r\n", "\n") served = read("QUESTIONS.md") note = read("served-notes/derive-0904-L7-transfer.md") m = re.search(r"", "\n".join(note.split("\n")[:60])) fields = dict(re.match(r"^([a-z]+):\s*(.*)$", l.strip()).groups() for l in m.group(1).split("\n") if re.match(r"^[a-z]+:\s", l.strip())) new_verdict = fields["verdict"] # the pre-#152 text, as it appears in the served registry rows old_verdict = ("No transfer mechanism in the corpus reaches L7, DERIVED: the union-bound transfer is vacuous " "already in the period average from x = 11 (the exact CRT budget sum of 1/(p - 1) over " "3 <= p <= x passes 1 at x = 11), and the sieve-on-holes transfer is the Bruedern-Fouvry vector " "sieve, whose coupled unconditional form lands at 2(1 + sqrt e) = 5.2974 above beta2 and whose " "decoupled form needs the sup-over-positions remainder law that item 0 ruled a truth gap; L7 stays " "a legal OPEN statement with no mechanism, and the conjectural A = 1 is truth-side evidence only.") n = served.count(old_verdict) print("occurrences of the stale verdict in served QUESTIONS.md:", n) assert n == 2, "expected the stale text exactly twice (section 1 and section 2)" assert new_verdict not in served, "the current verdict is already in the served index" fixed = served.replace(old_verdict, new_verdict) io.open("QUESTIONS.md.corrected", "w", encoding="utf-8", newline="").write(fixed) diff = difflib.unified_diff(served.split("\n"), fixed.split("\n"), fromfile="a/research/QUESTIONS.md", tofile="b/research/QUESTIONS.md", lineterm="", n=0) patch = "\n".join(diff) + "\n" io.open("questions-row37.patch", "w", encoding="utf-8", newline="").write(patch) print("patch lines:", patch.count("\n")) print() for ln in patch.split("\n")[:3]: print(ln) print() # check the two corrected lines still have 6 cells and the right id for ln in fixed.split("\n"): if "`Q-derive-0904-L7-transfer`" in ln: cells = [c for c in ln.split("|")] print("corrected line cells:", len(cells) - 2, "| starts:", ln[:60]) break print() print("sha256 served :", hashlib.sha256(served.encode()).hexdigest()) print("sha256 corrected :", hashlib.sha256(fixed.encode()).hexdigest()) print() print("NEW ROW 37 VERDICT (verbatim from the note):") print(new_verdict)