base_storage.py 835 B

123456789101112131415161718192021222324252627282930313233343536
  1. """Abstract interface for file storage implementations."""
  2. from abc import ABC, abstractmethod
  3. from collections.abc import Generator
  4. class BaseStorage(ABC):
  5. """Interface for file storage."""
  6. def __init__(self): # noqa: B027
  7. pass
  8. @abstractmethod
  9. def save(self, filename, data):
  10. raise NotImplementedError
  11. @abstractmethod
  12. def load_once(self, filename: str) -> bytes:
  13. raise NotImplementedError
  14. @abstractmethod
  15. def load_stream(self, filename: str) -> Generator:
  16. raise NotImplementedError
  17. @abstractmethod
  18. def download(self, filename, target_filepath):
  19. raise NotImplementedError
  20. @abstractmethod
  21. def exists(self, filename):
  22. raise NotImplementedError
  23. @abstractmethod
  24. def delete(self, filename):
  25. raise NotImplementedError