MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / get_base64_from_file

Function get_base64_from_file

prepop_cache.py:189–197  ·  view source on GitHub ↗
(file_path: str)

Source from the content-addressed store, hash-verified

187 return base64s
188
189def get_base64_from_file(file_path: str) -> str:
190 with open(file_path, "rb") as file:
191 content = file.read()
192 # parse it as json, then dump it as json with minimal whitespace
193 json_content = json.loads(content)
194 minimal_json_content = json.dumps(json_content)
195 if minimal_json_content == "{}":
196 raise ValueError(f"File {file_path} is empty")
197 return base64.b64encode(minimal_json_content.encode("utf-8")).decode("utf-8")
198
199if __name__ == "__main__":
200 prepop_cache()

Callers 1

get_base64s_from_dirFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected