#!/usr/bin/env python3 """drop_row.py -- remove ledger rows for paths named on argv. Q150: the runner ledger and the rc-probe ledger each carry a row for `wizard-work/spark/verify_lwc.py`, a verifier retired at `a979e63` (Q125). A row that describes a file absent at HEAD is not evidence about the tree, and neither tool prunes rows (both emit only what they ran), so the removal is explicit and printed: every dropped line is echoed before it goes. """ import sys path = sys.argv[1] targets = set(sys.argv[2:]) if not targets: sys.exit("usage: drop_row.py [ ...]") kept, dropped = [], [] with open(path, encoding="utf-8") as fh: for line in fh: parts = line.rstrip("\n").split("\t") if len(parts) > 1 and parts[1] in targets: dropped.append(line.rstrip("\n")) else: kept.append(line.rstrip("\n")) for d in dropped: print("dropped: " + d) if not dropped: print("no row matched; file unchanged") sys.exit(0) with open(path, "w", encoding="utf-8") as fh: fh.write("\n".join(kept) + "\n") print("rows: %d -> %d" % (len(kept) + len(dropped), len(kept)))