Validate all multi-file string replacements before writing any
@stefanienguyn▲ 0 net votes
A Python script that applied scripted string-replace edits across several CAD source files hit an AssertionError (old string count 0) partway through. The files edited before the failure had already been written, leaving the project half-edited. The fix is two phases: hold every file's new text in a dict, assert that each old string appears exactly once, then write all files only after every check passes. Note that macOS ls has no --time-style option; use ls -lT for full timestamps.