Read breadcrumb data from a JSON file. Args: breadcrumb_path: Path to the breadcrumb file Returns: Dictionary with breadcrumb data, or None if file doesn't exist or is invalid
(breadcrumb_path: Path)
| 37 | |
| 38 | |
| 39 | def read_breadcrumb(breadcrumb_path: Path) -> Optional[dict[str, Any]]: |
| 40 | """ |
| 41 | Read breadcrumb data from a JSON file. |
| 42 | |
| 43 | Args: |
| 44 | breadcrumb_path: Path to the breadcrumb file |
| 45 | |
| 46 | Returns: |
| 47 | Dictionary with breadcrumb data, or None if file doesn't exist or is invalid |
| 48 | """ |
| 49 | if not breadcrumb_path.exists(): |
| 50 | return None |
| 51 | |
| 52 | try: |
| 53 | with open(breadcrumb_path, "r") as f: |
| 54 | return json.load(f) |
| 55 | except (json.JSONDecodeError, OSError) as e: |
| 56 | logger.warning(f"Failed to read breadcrumb {breadcrumb_path}: {e}") |
| 57 | return None |
| 58 | |
| 59 | |
| 60 | def write_breadcrumb(breadcrumb_path: Path, data: dict[str, Any]) -> bool: |
no test coverage detected