(self)
| 94 | self._update_cache() |
| 95 | |
| 96 | def _load_cache(self) -> None: |
| 97 | if self._cache_loaded: |
| 98 | return |
| 99 | try: |
| 100 | self.cache_dir.mkdir(parents=True, exist_ok=True) |
| 101 | if self.cache_file.exists(): |
| 102 | cache_age = time.time() - self.cache_file.stat().st_mtime |
| 103 | if cache_age < self.CACHE_TTL: |
| 104 | try: |
| 105 | self.content = json.loads(self.cache_file.read_text()) |
| 106 | except json.JSONDecodeError: |
| 107 | self.content = None |
| 108 | except OSError: |
| 109 | # Cache directory might be unwritable; ignore. |
| 110 | pass |
| 111 | |
| 112 | self._cache_loaded = True |
| 113 | |
| 114 | def _update_cache(self) -> None: |
| 115 | try: |
no test coverage detected