Read a JSON file, returning None on any error.
(path)
| 146 | |
| 147 | @staticmethod |
| 148 | def _read_json(path) -> dict | None: |
| 149 | """Read a JSON file, returning None on any error.""" |
| 150 | try: |
| 151 | with open(path, "r", encoding="utf-8") as f: |
| 152 | return json.load(f) |
| 153 | except (json.JSONDecodeError, OSError) as e: |
| 154 | print(f"Warning: corrupt {Path(path).name}: {e}") |
| 155 | return None |
| 156 | |
| 157 | def _save_doc(self, doc_id: str): |
| 158 | doc = self.documents[doc_id].copy() |
no test coverage detected