diff options
author | Matthias Baumgartner <dev@igsor.net> | 2022-11-25 14:39:18 +0100 |
---|---|---|
committer | Matthias Baumgartner <dev@igsor.net> | 2022-11-25 14:39:18 +0100 |
commit | 9ce32829b2bb85907a34a543bfcaa9183d1e362c (patch) | |
tree | 200dcfcdf98d9cba6f8ada52a873484289db6dbd /bsie/utils | |
parent | b96c6e2096c387b70e2a4c1f0bc53b6044a0dc6f (diff) | |
download | bsie-9ce32829b2bb85907a34a543bfcaa9183d1e362c.tar.gz bsie-9ce32829b2bb85907a34a543bfcaa9183d1e362c.tar.bz2 bsie-9ce32829b2bb85907a34a543bfcaa9183d1e362c.zip |
string conversion and equality checks
Diffstat (limited to 'bsie/utils')
-rw-r--r-- | bsie/utils/node.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/bsie/utils/node.py b/bsie/utils/node.py index 3a0f06b..c9c494f 100644 --- a/bsie/utils/node.py +++ b/bsie/utils/node.py @@ -7,8 +7,8 @@ Author: Matthias Baumgartner, 2022 # imports import typing -# inner-module imports -from bsie.utils.bsfs import URI +# bsie imports +from bsie.utils.bsfs import URI, typename # exports __all__: typing.Sequence[str] = ( @@ -36,4 +36,18 @@ class Node(): self.node_type = URI(node_type) self.uri = URI(uri) + def __eq__(self, other: typing.Any) -> bool: + return isinstance(other, Node) \ + and other.node_type == self.node_type \ + and other.uri == self.uri + + def __hash__(self) -> int: + return hash((type(self), self.node_type, self.uri)) + + def __str__(self) -> str: + return f'{typename(self)}({self.node_type}, {self.uri})' + + def __repr__(self) -> str: + return f'{typename(self)}({self.node_type}, {self.uri})' + ## EOF ## |