A graph file's data with one copy of each string its rows repeat.
(path)
| 721 | |
| 722 | |
| 723 | def read_graph_json(path) -> dict: |
| 724 | """A graph file's data with one copy of each string its rows repeat.""" |
| 725 | shared: dict[str, str] = {} |
| 726 | |
| 727 | def share(row: dict) -> dict: |
| 728 | for field, value in row.items(): |
| 729 | if type(value) is str: |
| 730 | row[field] = shared.setdefault(value, value) |
| 731 | return row |
| 732 | |
| 733 | return json.loads(Path(path).read_text(encoding="utf-8"), object_hook=share) |
| 734 | |
| 735 | |
| 736 | def consumed(rows: list): |
no outgoing calls
no test coverage detected