MCPcopy
hub / github.com/GitGuardian/ggshield / load_cache

Method load_cache

ggshield/core/cache.py:23–42  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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:

Callers 2

__init__Method · 0.95

Calls 6

update_cacheMethod · 0.95
is_gitignoredFunction · 0.90
gitignoreFunction · 0.90
UnexpectedErrorClass · 0.90
openMethod · 0.80
loadMethod · 0.45

Tested by 1