()
| 179 | |
| 180 | |
| 181 | def main(): |
| 182 | ap = argparse.ArgumentParser(description=__doc__) |
| 183 | ap.add_argument("paths", nargs="+") |
| 184 | ap.add_argument("--write", action="store_true", help="Apply (default: dry run)") |
| 185 | args = ap.parse_args() |
| 186 | import collections |
| 187 | counts = collections.Counter() |
| 188 | changed, skipped = [], [] |
| 189 | for path in expand(args.paths): |
| 190 | if process_file(path, args.write, counts, skipped): |
| 191 | changed.append(os.path.basename(path)) |
| 192 | mode = "WROTE" if args.write else "DRY RUN — would change" |
| 193 | print(f"{mode} {len(changed)} post(s); skipped {len(skipped)} Steve-Hannah post(s).") |
| 194 | print(f"Total substitutions: {sum(counts.values())}") |
| 195 | for k, n in counts.most_common(): |
| 196 | print(f" {n:4d} {k}") |
| 197 | return 0 |
| 198 | |
| 199 | |
| 200 | if __name__ == "__main__": |
no test coverage detected