MCPcopy
hub / github.com/LawRefBook/Laws / get

Method get

scripts/request.py:117–128  ·  view source on GitHub ↗
(self, key: str, type: CacheType, filetype=None)

Source from the content-addressed store, hash-verified

115 return full_path.exists(), full_path
116
117 def get(self, key: str, type: CacheType, filetype=None):
118 full_path = self.path(key, type, filetype)
119 if not full_path.exists():
120 return None
121 try:
122 with open(full_path, "r") as f:
123 if filetype == "json":
124 return json.load(f)
125 return f.read()
126 except Exception as e:
127 logger.error(e)
128 return None
129
130 def set(self, key: str, type: CacheType, data: Any, filetype=None):
131 full_path = self.path(key, type, filetype)

Callers 5

create_lawMethod · 0.80
getLawListMethod · 0.80
get_law_detailMethod · 0.80
get_htmlMethod · 0.80

Calls 1

pathMethod · 0.95

Tested by

no test coverage detected