Return the extension at `path` as a base64-encoded archive. A directory is zipped with its contents at the archive root, a file is read as-is, and anything else is assumed to already be base64-encoded bytes.
(path: str)
| 126 | |
| 127 | |
| 128 | def _encode_extension(path: str) -> str: |
| 129 | """Return the extension at `path` as a base64-encoded archive. |
| 130 | |
| 131 | A directory is zipped with its contents at the archive root, a file is read |
| 132 | as-is, and anything else is assumed to already be base64-encoded bytes. |
| 133 | """ |
| 134 | if os.path.isdir(path): |
| 135 | return _zip_directory(path, root=path) |
| 136 | if os.path.isfile(path): |
| 137 | with open(path, "rb") as extension: |
| 138 | return base64.b64encode(extension.read()).decode("utf-8") |
| 139 | return path |
| 140 | |
| 141 | |
| 142 | def import_cdp() -> None: |
no test coverage detected