| 123456789101112131415161718192021 |
- import pathlib
- from .file_blob import file_blob
- from .exceptions import not_exists
- from .exceptions import not_readable
- class file_loader:
- def __init__(self, source: pathlib.Path) -> None:
- if not source.is_file():
- raise not_exists(source)
- self.__source = source
- def read(self) -> file_blob:
- try:
- with self.__source.open("rb") as handler:
- return file_blob(handler.read())
- except Exception as error:
- raise not_readable(self.__source, error)
-
|