aboutsummaryrefslogtreecommitdiffstats
path: root/bsie/base/reader.py
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2022-11-25 14:59:17 +0100
committerMatthias Baumgartner <dev@igsor.net>2022-11-25 14:59:17 +0100
commita294bbe0622911bcd6df37c38865a4c0eb290593 (patch)
treef038ed8d4f04c63991939e13e61ae170de4e2c57 /bsie/base/reader.py
parent9389c741bdbbca9adbff6099d440706cd63deac4 (diff)
parent3e6a69ce7f109f0fd4352507ad60d58d4cbd24a7 (diff)
downloadbsie-a294bbe0622911bcd6df37c38865a4c0eb290593.tar.gz
bsie-a294bbe0622911bcd6df37c38865a4c0eb290593.tar.bz2
bsie-a294bbe0622911bcd6df37c38865a4c0eb290593.zip
Merge branch 'mb/tools' into develop
Diffstat (limited to 'bsie/base/reader.py')
-rw-r--r--bsie/base/reader.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/bsie/base/reader.py b/bsie/base/reader.py
index f29e451..b7eabf7 100644
--- a/bsie/base/reader.py
+++ b/bsie/base/reader.py
@@ -12,12 +12,11 @@ Author: Matthias Baumgartner, 2022
import abc
import typing
-# inner-module imports
+# bsie imports
from bsie.utils.bsfs import URI, typename
# exports
__all__: typing.Sequence[str] = (
- 'Aggregator',
'Reader',
)
@@ -27,20 +26,20 @@ __all__: typing.Sequence[str] = (
class Reader(abc.ABC):
"""Read and return some content from a file."""
- # In what data structure content is returned
- CONTENT_TYPE = typing.Union[typing.Any]
- # NOTE: Child classes must also assign a typing.Union even if there's
- # only one options
-
def __str__(self) -> str:
return typename(self)
def __repr__(self) -> str:
return f'{typename(self)}()'
- # FIXME: How about using contexts instead of calls?
+ 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) -> CONTENT_TYPE:
+ 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.
"""