aboutsummaryrefslogtreecommitdiffstats
path: root/bsie/utils
diff options
context:
space:
mode:
Diffstat (limited to 'bsie/utils')
-rw-r--r--bsie/utils/__init__.py22
-rw-r--r--bsie/utils/bsfs.py27
-rw-r--r--bsie/utils/namespaces.py27
-rw-r--r--bsie/utils/node.py53
4 files changed, 129 insertions, 0 deletions
diff --git a/bsie/utils/__init__.py b/bsie/utils/__init__.py
new file mode 100644
index 0000000..bd22236
--- /dev/null
+++ b/bsie/utils/__init__.py
@@ -0,0 +1,22 @@
+"""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 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
new file mode 100644
index 0000000..0b88479
--- /dev/null
+++ b/bsie/utils/bsfs.py
@@ -0,0 +1,27 @@
+"""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 import Open, schema
+from bsfs.apps.init import init_sparql_store
+from bsfs.namespace import Namespace
+from bsfs.utils import URI, typename, uuid
+
+# exports
+__all__: typing.Sequence[str] = (
+ 'Namespace',
+ 'Open',
+ 'URI',
+ 'init_sparql_store',
+ 'schema',
+ 'typename',
+ 'uuid',
+ )
+
+## EOF ##
diff --git a/bsie/utils/namespaces.py b/bsie/utils/namespaces.py
new file mode 100644
index 0000000..a29fc1b
--- /dev/null
+++ b/bsie/utils/namespaces.py
@@ -0,0 +1,27 @@
+"""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
+
+# inner-module imports
+from . import bsfs as _bsfs
+
+# constants
+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] = (
+ 'bse',
+ 'bsfs',
+ 'bsm',
+ 'xsd',
+ )
+
+## EOF ##
diff --git a/bsie/utils/node.py b/bsie/utils/node.py
new file mode 100644
index 0000000..ecf39cd
--- /dev/null
+++ b/bsie/utils/node.py
@@ -0,0 +1,53 @@
+"""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
+
+# bsie imports
+from bsie.utils import bsfs
+
+# exports
+__all__: typing.Sequence[str] = (
+ 'Node',
+ )
+
+
+## code ##
+
+class Node():
+ """Lightweight Node, disconnected from any bsfs structures."""
+
+ # node type.
+ node_type: bsfs.URI
+
+ # node URI.
+ uri: bsfs.URI
+
+ def __init__(
+ self,
+ node_type: bsfs.URI,
+ uri: bsfs.URI,
+ ):
+ # assign members
+ self.node_type = bsfs.URI(node_type)
+ self.uri = bsfs.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'{bsfs.typename(self)}({self.node_type}, {self.uri})'
+
+ def __repr__(self) -> str:
+ return f'{bsfs.typename(self)}({self.node_type}, {self.uri})'
+
+## EOF ##