Spaces:
Sleeping
Sleeping
Download adsp/storage/object_store.py from thanhnv2323/humanize-text-python: direct link, hf CLI and curl.
- Browser
- Download file 558 Bytes
-
https://huggingface.co/spaces/thanhnv2323/humanize-text-python/resolve/main/adsp/storage/object_store.py
- Command line
-
hf download hf://spaces/thanhnv2323/humanize-text-python/adsp/storage/object_store.py
-
curl -L -o object_store.py https://huggingface.co/spaces/thanhnv2323/humanize-text-python/resolve/main/adsp/storage/object_store.py
558 Bytes
| """Object storage shim.""" | |
| from __future__ import annotations | |
| from pathlib import Path | |
| from typing import Dict | |
| _STORE: Dict[str, Dict[str, bytes]] = {} | |
| def put(bucket: str, file_path: Path) -> None: | |
| _STORE.setdefault(bucket, {})[file_path.name] = file_path.read_bytes() | |
| def get(bucket: str, key: str) -> bytes: | |
| return _STORE[bucket][key] | |
| def put_bytes(bucket: str, key: str, payload: bytes) -> None: | |
| _STORE.setdefault(bucket, {})[key] = payload | |
| def list_keys(bucket: str) -> list[str]: | |
| return sorted(_STORE.get(bucket, {}).keys()) | |