(fn: Path, new: list[str])
| 228 | |
| 229 | |
| 230 | def update_file(fn: Path, new: list[str]) -> None: |
| 231 | with fn.open("r") as f: |
| 232 | lines = f.read().splitlines() |
| 233 | istart, iend = ( |
| 234 | i |
| 235 | for i, line in enumerate(lines) |
| 236 | if re.match(r"\s*#\s*autogenerated:\s+(start|end)", line) |
| 237 | ) |
| 238 | lines[istart + 1 : iend] = new + [""] |
| 239 | |
| 240 | with fn.open("w") as f: |
| 241 | f.write("\n".join(lines)) |
| 242 | f.write("\n") |
| 243 | |
| 244 | |
| 245 | def parse_cmdline() -> argparse.Namespace: |
no test coverage detected