From d2b4a528465dc01e8db92b61293c458c7911a333 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Mon, 31 Oct 2022 12:21:22 +0100 Subject: essential interfaces (reader, extractor, errors) --- bsie/utils/node.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 bsie/utils/node.py (limited to 'bsie/utils/node.py') diff --git a/bsie/utils/node.py b/bsie/utils/node.py new file mode 100644 index 0000000..60863a4 --- /dev/null +++ b/bsie/utils/node.py @@ -0,0 +1,39 @@ +"""Lighweight Node to bridge to BSFS. + +Part of the bsie module. +A copy of the license is provided with the project. +Author: Matthias Baumgartner, 2022 +""" +# imports +import typing + +# inner-module imports +from bsie.utils.bsfs import URI + +# exports +__all__: typing.Sequence[str] = ( + 'Node' + ) + + +## code ## + +class Node(): + """Lightweight Node, disconnected from any bsfs structures.""" + + # node type. + node_type: URI + + # node URI. + uri: URI + + def __init__( + self, + node_type: URI, + uri: URI, + ): + # assign members + self.node_type = URI(node_type) + self.uri = URI(uri) + +## EOF ## -- cgit v1.2.3 From e174a25585e64eb1b0759440cad48d642dd31829 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Fri, 25 Nov 2022 14:31:29 +0100 Subject: use schema and predicate types in extractors --- bsie/utils/node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bsie/utils/node.py') diff --git a/bsie/utils/node.py b/bsie/utils/node.py index 60863a4..3a0f06b 100644 --- a/bsie/utils/node.py +++ b/bsie/utils/node.py @@ -12,7 +12,7 @@ from bsie.utils.bsfs import URI # exports __all__: typing.Sequence[str] = ( - 'Node' + 'Node', ) -- cgit v1.2.3 From 9ce32829b2bb85907a34a543bfcaa9183d1e362c Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Fri, 25 Nov 2022 14:39:18 +0100 Subject: string conversion and equality checks --- bsie/utils/node.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'bsie/utils/node.py') 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 ## -- cgit v1.2.3 From 49cf03fc212c813862453de5352436dc90d1e458 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Thu, 15 Dec 2022 16:50:53 +0100 Subject: imports and init files --- bsie/utils/node.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'bsie/utils/node.py') diff --git a/bsie/utils/node.py b/bsie/utils/node.py index c9c494f..ecf39cd 100644 --- a/bsie/utils/node.py +++ b/bsie/utils/node.py @@ -8,7 +8,7 @@ Author: Matthias Baumgartner, 2022 import typing # bsie imports -from bsie.utils.bsfs import URI, typename +from bsie.utils import bsfs # exports __all__: typing.Sequence[str] = ( @@ -22,19 +22,19 @@ class Node(): """Lightweight Node, disconnected from any bsfs structures.""" # node type. - node_type: URI + node_type: bsfs.URI # node URI. - uri: URI + uri: bsfs.URI def __init__( self, - node_type: URI, - uri: URI, + node_type: bsfs.URI, + uri: bsfs.URI, ): # assign members - self.node_type = URI(node_type) - self.uri = URI(uri) + self.node_type = bsfs.URI(node_type) + self.uri = bsfs.URI(uri) def __eq__(self, other: typing.Any) -> bool: return isinstance(other, Node) \ @@ -45,9 +45,9 @@ class Node(): return hash((type(self), self.node_type, self.uri)) def __str__(self) -> str: - return f'{typename(self)}({self.node_type}, {self.uri})' + return f'{bsfs.typename(self)}({self.node_type}, {self.uri})' def __repr__(self) -> str: - return f'{typename(self)}({self.node_type}, {self.uri})' + return f'{bsfs.typename(self)}({self.node_type}, {self.uri})' ## EOF ## -- cgit v1.2.3