(file_path: str)
| 187 | return base64s |
| 188 | |
| 189 | def 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 | |
| 199 | if __name__ == "__main__": |
| 200 | prepop_cache() |
no outgoing calls
no test coverage detected