| 200 | ) |
| 201 | |
| 202 | def on_finish(self) -> None: |
| 203 | counts: list[tuple[tuple[int, int, int, int], str]] = sorted( |
| 204 | ((c, p) for p, c in self.counts.items()), reverse=True |
| 205 | ) |
| 206 | total_counts = tuple(sum(c[i] for c, p in counts) for i in range(4)) |
| 207 | with open(os.path.join(self.output_dir, "linecount.txt"), "w") as f: |
| 208 | f.write("{:7} {:7} {:6} {:6} total\n".format(*total_counts)) |
| 209 | for c, p in counts: |
| 210 | f.write(f"{c[0]:7} {c[1]:7} {c[2]:6} {c[3]:6} {p}\n") |
| 211 | |
| 212 | |
| 213 | register_reporter("linecount", LineCountReporter) |