| 15 | |
| 16 | |
| 17 | def run(args: list[str]) -> None: |
| 18 | assert len(args) == 1, "codespell_errors.txt" |
| 19 | cache = {} |
| 20 | done = set() |
| 21 | with open(args[0]) as f: |
| 22 | lines = f.read().splitlines() |
| 23 | |
| 24 | for line in sorted(lines): |
| 25 | i = line.find(" ==> ") |
| 26 | if i > 0: |
| 27 | flds = line[:i].split(":") |
| 28 | if len(flds) >= 2: |
| 29 | filename, line_num = flds[:2] |
| 30 | if filename not in cache: |
| 31 | with open(filename) as f: |
| 32 | cache[filename] = f.read().splitlines() |
| 33 | supp = cache[filename][int(line_num) - 1] |
| 34 | if supp not in done: |
| 35 | print(supp) |
| 36 | done.add(supp) |
| 37 | |
| 38 | |
| 39 | if __name__ == "__main__": |