aboutsummaryrefslogtreecommitdiffstats
path: root/bsie/base
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2022-11-25 14:39:18 +0100
committerMatthias Baumgartner <dev@igsor.net>2022-11-25 14:39:18 +0100
commit9ce32829b2bb85907a34a543bfcaa9183d1e362c (patch)
tree200dcfcdf98d9cba6f8ada52a873484289db6dbd /bsie/base
parentb96c6e2096c387b70e2a4c1f0bc53b6044a0dc6f (diff)
downloadbsie-9ce32829b2bb85907a34a543bfcaa9183d1e362c.tar.gz
bsie-9ce32829b2bb85907a34a543bfcaa9183d1e362c.tar.bz2
bsie-9ce32829b2bb85907a34a543bfcaa9183d1e362c.zip
string conversion and equality checks
Diffstat (limited to 'bsie/base')
-rw-r--r--bsie/base/extractor.py7
-rw-r--r--bsie/base/reader.py6
2 files changed, 13 insertions, 0 deletions
diff --git a/bsie/base/extractor.py b/bsie/base/extractor.py
index 7acf2bd..2fc4f18 100644
--- a/bsie/base/extractor.py
+++ b/bsie/base/extractor.py
@@ -63,6 +63,13 @@ class Extractor(abc.ABC):
def __repr__(self) -> str:
return f'{typename(self)}()'
+ def __eq__(self, other: typing.Any) -> bool:
+ return isinstance(other, type(self)) \
+ and self.CONTENT_READER == other.CONTENT_READER \
+ and self.schema == other.schema
+
+ def __hash__(self) -> int:
+ return hash((type(self), self.CONTENT_READER, self.schema))
def predicates(self) -> typing.Iterator[_schema.Predicate]:
"""Return the predicates that may be part of extracted triples."""
diff --git a/bsie/base/reader.py b/bsie/base/reader.py
index e59abef..b7eabf7 100644
--- a/bsie/base/reader.py
+++ b/bsie/base/reader.py
@@ -32,6 +32,12 @@ class Reader(abc.ABC):
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*.