| 21 | self.load_cache() |
| 22 | |
| 23 | def load_cache(self) -> None: |
| 24 | if self.cache_path.is_file() and is_gitignored(self.cache_path) is False: |
| 25 | gitignore(self.cache_path) |
| 26 | |
| 27 | if not self.cache_path.is_file() or self.cache_path.stat().st_size == 0: |
| 28 | return |
| 29 | |
| 30 | try: |
| 31 | f = self.cache_path.open() |
| 32 | except PermissionError: |
| 33 | # Hotfix: for the time being we skip cache handling if permission denied |
| 34 | return |
| 35 | with f: |
| 36 | try: |
| 37 | _cache: Dict[str, Any] = json.load(f) |
| 38 | except Exception as e: |
| 39 | raise UnexpectedError( |
| 40 | f"Parsing error while reading {self.cache_path}:\n{str(e)}" |
| 41 | ) |
| 42 | self.update_cache(**_cache) |
| 43 | |
| 44 | def update_cache(self, **kwargs: Any) -> None: |
| 45 | if SECRETS_CACHE_KEY in kwargs: |