"""The Reader classes return high-level content structures from files. The Reader fulfills two purposes: First, it brokers between multiple libraries and file formats. Second, it separates multiple aspects of a file into distinct content types. Part of the bsie module. A copy of the license is provided with the project. Author: Matthias Baumgartner, 2022 """ # imports import abc import typing # bsie imports from bsie.utils.bsfs import URI, typename # exports __all__: typing.Sequence[str] = ( 'Reader', ) ## code ## class Reader(abc.ABC): """Read and return some content from a file.""" def __str__(self) -> str: return typename(self) def __repr__(self) -> str: return f'{typename(self)}()' def __eq__(self, other: typing.Any) -> bool: return isinstance(other, type(self)) def __hash__(self) -> int: return hash(type(self)) @abc.abstractmethod def __call__(self, path: URI) -> typing.Any: """Return some content of the file at *path*. Raises a `ReaderError` if the reader cannot make sense of the file format. """ ## EOF ##