"""Rename send_result -> send in a single test file (idempotent: only renames occurrences of send_result).""" from __future__ import annotations import sys from pathlib import Path def main() -> int: rel = sys.argv[1] p = Path(rel) with p.open("r", encoding="utf-8", newline="") as f: content = f.read() has_crlf = "\r\n" in content new_content = content.replace("send_result", "send") with p.open("w", encoding="utf-8", newline="") as f: f.write(new_content) remaining = new_content.count("send_result") before = content.count("send_result") print(f"{rel}: renamed {before - remaining} occurrences; remaining={remaining}") return 0 if __name__ == "__main__": raise SystemExit(main())