aboutsummaryrefslogtreecommitdiffstats
path: root/bsie/base
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2022-11-25 14:36:27 +0100
committerMatthias Baumgartner <dev@igsor.net>2022-11-25 14:36:27 +0100
commitb96c6e2096c387b70e2a4c1f0bc53b6044a0dc6f (patch)
tree0db971d173db4612ada4d87cc5adef601b8f0e9e /bsie/base
parente174a25585e64eb1b0759440cad48d642dd31829 (diff)
downloadbsie-b96c6e2096c387b70e2a4c1f0bc53b6044a0dc6f.tar.gz
bsie-b96c6e2096c387b70e2a4c1f0bc53b6044a0dc6f.tar.bz2
bsie-b96c6e2096c387b70e2a4c1f0bc53b6044a0dc6f.zip
decouple readers and extractors; use strings for reference and repeated type annotations
Diffstat (limited to 'bsie/base')
-rw-r--r--bsie/base/extractor.py5
-rw-r--r--bsie/base/reader.py11
2 files changed, 4 insertions, 12 deletions
diff --git a/bsie/base/extractor.py b/bsie/base/extractor.py
index a6a69c6..7acf2bd 100644
--- a/bsie/base/extractor.py
+++ b/bsie/base/extractor.py
@@ -8,8 +8,7 @@ Author: Matthias Baumgartner, 2022
import abc
import typing
-# inner-module imports
-from . import reader
+# bsie imports
from bsie.utils import node
from bsie.utils.bsfs import schema as _schema, typename
@@ -50,7 +49,7 @@ class Extractor(abc.ABC):
"""Produce (node, predicate, value)-triples from some content."""
# what type of content is expected (i.e. reader subclass).
- CONTENT_READER: typing.Optional[typing.Type[reader.Reader]] = None
+ CONTENT_READER: typing.Optional[str] = None
# extractor schema.
schema: _schema.Schema
diff --git a/bsie/base/reader.py b/bsie/base/reader.py
index f29e451..e59abef 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,14 @@ __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?
@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.
"""