AbsReaderWriter.py 452 B

1234567891011121314151617
  1. from abc import ABC, abstractmethod
  2. class AbsReaderWriter(ABC):
  3. MODE_TXT = "text"
  4. MODE_BIN = "binary"
  5. @abstractmethod
  6. def read(self, path: str, mode=MODE_TXT):
  7. raise NotImplementedError
  8. @abstractmethod
  9. def write(self, content: str, path: str, mode=MODE_TXT):
  10. raise NotImplementedError
  11. @abstractmethod
  12. def read_offset(self, path: str, offset=0, limit=None) -> bytes:
  13. raise NotImplementedError