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/__init__.py | 20 ++++++++++++++++++++ bsie/utils/bsfs.py | 20 ++++++++++++++++++++ bsie/utils/node.py | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 bsie/utils/__init__.py create mode 100644 bsie/utils/bsfs.py create mode 100644 bsie/utils/node.py (limited to 'bsie/utils') diff --git a/bsie/utils/__init__.py b/bsie/utils/__init__.py new file mode 100644 index 0000000..1137187 --- /dev/null +++ b/bsie/utils/__init__.py @@ -0,0 +1,20 @@ +"""Common tools and definitions. + +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 . import bsfs +from . import node + +# exports +__all__: typing.Sequence[str] = ( + 'bsfs', + 'node', + ) + +## EOF ## diff --git a/bsie/utils/bsfs.py b/bsie/utils/bsfs.py new file mode 100644 index 0000000..33eb178 --- /dev/null +++ b/bsie/utils/bsfs.py @@ -0,0 +1,20 @@ +"""BSFS bridge, provides BSFS bindings for BSIE. + +Part of the bsie module. +A copy of the license is provided with the project. +Author: Matthias Baumgartner, 2022 +""" +# imports +import typing + +# bsfs imports +from bsfs.utils import URI +from bsfs.utils import typename + +# exports +__all__: typing.Sequence[str] = ( + 'URI', + 'typename', + ) + +## EOF ## 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 2da348c638ac5058d5acf09ab5df323ee04503d5 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Mon, 31 Oct 2022 14:14:42 +0100 Subject: constant, filesize, and filename extractors --- bsie/utils/__init__.py | 2 ++ bsie/utils/bsfs.py | 5 +++-- bsie/utils/namespaces.py | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 bsie/utils/namespaces.py (limited to 'bsie/utils') diff --git a/bsie/utils/__init__.py b/bsie/utils/__init__.py index 1137187..bd22236 100644 --- a/bsie/utils/__init__.py +++ b/bsie/utils/__init__.py @@ -9,12 +9,14 @@ import typing # inner-module imports from . import bsfs +from . import namespaces as ns from . import node # exports __all__: typing.Sequence[str] = ( 'bsfs', 'node', + 'ns', ) ## EOF ## diff --git a/bsie/utils/bsfs.py b/bsie/utils/bsfs.py index 33eb178..1ae657c 100644 --- a/bsie/utils/bsfs.py +++ b/bsie/utils/bsfs.py @@ -8,11 +8,12 @@ Author: Matthias Baumgartner, 2022 import typing # bsfs imports -from bsfs.utils import URI -from bsfs.utils import typename +from bsfs.namespace import Namespace +from bsfs.utils import URI, typename # exports __all__: typing.Sequence[str] = ( + 'Namespace', 'URI', 'typename', ) diff --git a/bsie/utils/namespaces.py b/bsie/utils/namespaces.py new file mode 100644 index 0000000..67ccc71 --- /dev/null +++ b/bsie/utils/namespaces.py @@ -0,0 +1,25 @@ +"""Default namespaces used throughout BSIE. + +Part of the bsie module. +A copy of the license is provided with the project. +Author: Matthias Baumgartner, 2022 +""" +# imports +import typing + +# bsie imports +from . import bsfs as _bsfs + +# constants +bse = _bsfs.Namespace('http://bsfs.ai/schema/Entity#') +bsfs = _bsfs.Namespace('http://bsfs.ai/schema/') +bsm = _bsfs.Namespace('http://bsfs.ai/schema/meta#') + +# export +__all__: typing.Sequence[str] = ( + 'bse', + 'bsfs', + 'bsm', + ) + +## 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/bsfs.py | 2 ++ bsie/utils/namespaces.py | 3 ++- bsie/utils/node.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'bsie/utils') diff --git a/bsie/utils/bsfs.py b/bsie/utils/bsfs.py index 1ae657c..01ec5d1 100644 --- a/bsie/utils/bsfs.py +++ b/bsie/utils/bsfs.py @@ -8,6 +8,7 @@ Author: Matthias Baumgartner, 2022 import typing # bsfs imports +from bsfs import schema from bsfs.namespace import Namespace from bsfs.utils import URI, typename @@ -15,6 +16,7 @@ from bsfs.utils import URI, typename __all__: typing.Sequence[str] = ( 'Namespace', 'URI', + 'schema', 'typename', ) diff --git a/bsie/utils/namespaces.py b/bsie/utils/namespaces.py index 67ccc71..13be96b 100644 --- a/bsie/utils/namespaces.py +++ b/bsie/utils/namespaces.py @@ -7,13 +7,14 @@ Author: Matthias Baumgartner, 2022 # imports import typing -# bsie imports +# inner-module imports from . import bsfs as _bsfs # constants bse = _bsfs.Namespace('http://bsfs.ai/schema/Entity#') bsfs = _bsfs.Namespace('http://bsfs.ai/schema/') bsm = _bsfs.Namespace('http://bsfs.ai/schema/meta#') +xsd = _bsfs.Namespace('http://www.w3.org/2001/XMLSchema#') # export __all__: typing.Sequence[str] = ( 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') 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 3e6a69ce7f109f0fd4352507ad60d58d4cbd24a7 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Fri, 25 Nov 2022 14:43:12 +0100 Subject: builders and pipeline --- bsie/utils/bsfs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bsie/utils') diff --git a/bsie/utils/bsfs.py b/bsie/utils/bsfs.py index 01ec5d1..a4b7626 100644 --- a/bsie/utils/bsfs.py +++ b/bsie/utils/bsfs.py @@ -10,7 +10,7 @@ import typing # bsfs imports from bsfs import schema from bsfs.namespace import Namespace -from bsfs.utils import URI, typename +from bsfs.utils import URI, typename, uuid # exports __all__: typing.Sequence[str] = ( @@ -18,6 +18,7 @@ __all__: typing.Sequence[str] = ( 'URI', 'schema', 'typename', + 'uuid', ) ## EOF ## -- cgit v1.2.3 From 559e643bb1fa39feefd2eb73847ad9420daf1deb Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Wed, 14 Dec 2022 06:10:25 +0100 Subject: bsie extraction and info apps --- bsie/utils/namespaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bsie/utils') diff --git a/bsie/utils/namespaces.py b/bsie/utils/namespaces.py index 13be96b..2fcb2dc 100644 --- a/bsie/utils/namespaces.py +++ b/bsie/utils/namespaces.py @@ -13,7 +13,7 @@ from . import bsfs as _bsfs # constants bse = _bsfs.Namespace('http://bsfs.ai/schema/Entity#') bsfs = _bsfs.Namespace('http://bsfs.ai/schema/') -bsm = _bsfs.Namespace('http://bsfs.ai/schema/meta#') +bsm = _bsfs.Namespace('http://bsfs.ai/schema/Meta#') xsd = _bsfs.Namespace('http://www.w3.org/2001/XMLSchema#') # export -- cgit v1.2.3 From 3dc3e9a9b0fc8c9727f91359814866d3deae6e79 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Thu, 15 Dec 2022 16:42:07 +0100 Subject: minor fixes and comments --- bsie/utils/namespaces.py | 1 + 1 file changed, 1 insertion(+) (limited to 'bsie/utils') diff --git a/bsie/utils/namespaces.py b/bsie/utils/namespaces.py index 2fcb2dc..d6e1c72 100644 --- a/bsie/utils/namespaces.py +++ b/bsie/utils/namespaces.py @@ -21,6 +21,7 @@ __all__: typing.Sequence[str] = ( 'bse', 'bsfs', 'bsm', + 'xsd', ) ## 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/bsfs.py | 3 ++- bsie/utils/node.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'bsie/utils') diff --git a/bsie/utils/bsfs.py b/bsie/utils/bsfs.py index a4b7626..c48049d 100644 --- a/bsie/utils/bsfs.py +++ b/bsie/utils/bsfs.py @@ -8,13 +8,14 @@ Author: Matthias Baumgartner, 2022 import typing # bsfs imports -from bsfs import schema +from bsfs import Open, schema from bsfs.namespace import Namespace from bsfs.utils import URI, typename, uuid # exports __all__: typing.Sequence[str] = ( 'Namespace', + 'Open', 'URI', 'schema', 'typename', 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 From 057e09d6537bf5c39815661a75819081e3e5fda7 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Sun, 18 Dec 2022 13:37:59 +0100 Subject: adaptions to updates in bsfs --- bsie/utils/bsfs.py | 2 ++ bsie/utils/namespaces.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'bsie/utils') diff --git a/bsie/utils/bsfs.py b/bsie/utils/bsfs.py index c48049d..0b88479 100644 --- a/bsie/utils/bsfs.py +++ b/bsie/utils/bsfs.py @@ -9,6 +9,7 @@ import typing # bsfs imports from bsfs import Open, schema +from bsfs.apps.init import init_sparql_store from bsfs.namespace import Namespace from bsfs.utils import URI, typename, uuid @@ -17,6 +18,7 @@ __all__: typing.Sequence[str] = ( 'Namespace', 'Open', 'URI', + 'init_sparql_store', 'schema', 'typename', 'uuid', diff --git a/bsie/utils/namespaces.py b/bsie/utils/namespaces.py index d6e1c72..a29fc1b 100644 --- a/bsie/utils/namespaces.py +++ b/bsie/utils/namespaces.py @@ -11,10 +11,10 @@ import typing from . import bsfs as _bsfs # constants -bse = _bsfs.Namespace('http://bsfs.ai/schema/Entity#') -bsfs = _bsfs.Namespace('http://bsfs.ai/schema/') -bsm = _bsfs.Namespace('http://bsfs.ai/schema/Meta#') -xsd = _bsfs.Namespace('http://www.w3.org/2001/XMLSchema#') +bse = _bsfs.Namespace('http://bsfs.ai/schema/Entity') +bsfs = _bsfs.Namespace('http://bsfs.ai/schema', fsep='/') +bsm = _bsfs.Namespace('http://bsfs.ai/schema/Meta') +xsd = _bsfs.Namespace('http://www.w3.org/2001/XMLSchema') # export __all__: typing.Sequence[str] = ( -- cgit v1.2.3