()
| 579 | |
| 580 | |
| 581 | def main() -> None: |
| 582 | parser = argparse.ArgumentParser( |
| 583 | description="Convert binary cache files to JSON. " |
| 584 | "Create files in the same directory with extra .json extension." |
| 585 | ) |
| 586 | parser.add_argument( |
| 587 | "path", nargs="+", help="mypy cache data file to convert (.data.ff extension)" |
| 588 | ) |
| 589 | args = parser.parse_args() |
| 590 | fnams: list[str] = args.path |
| 591 | for fnam in fnams: |
| 592 | if fnam.endswith(".data.ff"): |
| 593 | is_data = True |
| 594 | elif fnam.endswith(".meta.ff"): |
| 595 | is_data = False |
| 596 | else: |
| 597 | sys.exit(f"error: Expected .data.ff or .meta.ff extension, but got {fnam}") |
| 598 | with open(fnam, "rb") as f: |
| 599 | data = f.read() |
| 600 | if is_data: |
| 601 | json_data = convert_binary_cache_to_json(data) |
| 602 | else: |
| 603 | data_file = fnam.removesuffix(".meta.ff") + ".data.ff" |
| 604 | json_data = convert_binary_cache_meta_to_json(data, data_file) |
| 605 | new_fnam = fnam + ".json" |
| 606 | with open(new_fnam, "w") as f: |
| 607 | json.dump(json_data, f) |
| 608 | print(f"{fnam} -> {new_fnam}") |
| 609 | |
| 610 | |
| 611 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…