diff options
author | Matthias Baumgartner <dev@igsor.net> | 2022-12-18 13:53:34 +0100 |
---|---|---|
committer | Matthias Baumgartner <dev@igsor.net> | 2022-12-18 13:53:34 +0100 |
commit | ebc3ccb5fdce950649bfcbf18f88ecb4a9dbcad0 (patch) | |
tree | 1815e3b4c10b6ffdd012650b0e768e4659b996e6 | |
parent | 1b570e45a4e99a4e7f9ad9d01b4fa93e38fbff38 (diff) | |
download | bsfs-ebc3ccb5fdce950649bfcbf18f88ecb4a9dbcad0.tar.gz bsfs-ebc3ccb5fdce950649bfcbf18f88ecb4a9dbcad0.tar.bz2 bsfs-ebc3ccb5fdce950649bfcbf18f88ecb4a9dbcad0.zip |
import fixes
-rw-r--r-- | bsfs/graph/__init__.py | 5 | ||||
-rw-r--r-- | bsfs/graph/ac/base.py | 14 | ||||
-rw-r--r-- | bsfs/graph/ac/null.py | 14 | ||||
-rw-r--r-- | bsfs/graph/graph.py | 6 | ||||
-rw-r--r-- | bsfs/schema/__init__.py | 2 | ||||
-rw-r--r-- | test/graph/test_graph.py | 6 |
6 files changed, 24 insertions, 23 deletions
diff --git a/bsfs/graph/__init__.py b/bsfs/graph/__init__.py index 3a131e9..82d2235 100644 --- a/bsfs/graph/__init__.py +++ b/bsfs/graph/__init__.py @@ -8,8 +8,11 @@ Author: Matthias Baumgartner, 2022 import typing # inner-module imports +from .graph import Graph # exports -__all__: typing.Sequence[str] = [] +__all__: typing.Sequence[str] = ( + 'Graph', + ) ## EOF ## diff --git a/bsfs/graph/ac/base.py b/bsfs/graph/ac/base.py index 70475d2..eef444b 100644 --- a/bsfs/graph/ac/base.py +++ b/bsfs/graph/ac/base.py @@ -9,7 +9,7 @@ import abc import typing # bsfs imports -from bsfs import schema as _schema +from bsfs import schema from bsfs.triple_store import TripleStoreBase from bsfs.utils import URI @@ -40,27 +40,27 @@ class AccessControlBase(abc.ABC): self.__user = URI(user) @abc.abstractmethod - def is_protected_predicate(self, pred: _schema.Predicate) -> bool: + def is_protected_predicate(self, pred: schema.Predicate) -> bool: """Return True if a predicate cannot be modified manually.""" @abc.abstractmethod - def create(self, node_type: _schema.Node, guids: typing.Iterable[URI]): + def create(self, node_type: schema.Node, guids: typing.Iterable[URI]): """Perform post-creation operations on nodes, e.g. ownership information.""" @abc.abstractmethod - def link_from_node(self, node_type: _schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: + def link_from_node(self, node_type: schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: """Return nodes for which outbound links can be written.""" @abc.abstractmethod - def link_to_node(self, node_type: _schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: + def link_to_node(self, node_type: schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: """Return nodes for which inbound links can be written.""" @abc.abstractmethod - def write_literal(self, node_type: _schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: + def write_literal(self, node_type: schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: """Return nodes to which literals can be attached.""" @abc.abstractmethod - def createable(self, node_type: _schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: + def createable(self, node_type: schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: """Return nodes that are allowed to be created.""" diff --git a/bsfs/graph/ac/null.py b/bsfs/graph/ac/null.py index a39b7b9..288a0da 100644 --- a/bsfs/graph/ac/null.py +++ b/bsfs/graph/ac/null.py @@ -8,7 +8,7 @@ Author: Matthias Baumgartner, 2022 import typing # bsfs imports -from bsfs import schema as _schema +from bsfs import schema from bsfs.namespace import ns from bsfs.utils import URI @@ -27,26 +27,26 @@ class NullAC(base.AccessControlBase): """ """ - def is_protected_predicate(self, pred: _schema.Predicate) -> bool: + def is_protected_predicate(self, pred: schema.Predicate) -> bool: """Return True if a predicate cannot be modified manually.""" return pred.uri == ns.bsm.t_created - def create(self, node_type: _schema.Node, guids: typing.Iterable[URI]): + def create(self, node_type: schema.Node, guids: typing.Iterable[URI]): """Perform post-creation operations on nodes, e.g. ownership information.""" - def link_from_node(self, node_type: _schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: + def link_from_node(self, node_type: schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: """Return nodes for which outbound links can be written.""" return guids - def link_to_node(self, node_type: _schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: + def link_to_node(self, node_type: schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: """Return nodes for which inbound links can be written.""" return guids - def write_literal(self, node_type: _schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: + def write_literal(self, node_type: schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: """Return nodes to which literals can be attached.""" return guids - def createable(self, node_type: _schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: + def createable(self, node_type: schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]: """Return nodes that are allowed to be created.""" return guids diff --git a/bsfs/graph/graph.py b/bsfs/graph/graph.py index 06271f6..d5e1b88 100644 --- a/bsfs/graph/graph.py +++ b/bsfs/graph/graph.py @@ -13,7 +13,7 @@ from bsfs.triple_store import TripleStoreBase from bsfs.utils import URI, typename # inner-module imports -from . import nodes +from . import nodes as _nodes # exports __all__: typing.Sequence[str] = ( @@ -55,11 +55,11 @@ class Graph(): """Return the store's local schema.""" return self.__backend.schema - def nodes(self, node_type: URI, guids: typing.Iterable[URI]) -> nodes.Nodes: """ + def nodes(self, node_type: URI, guids: typing.Iterable[URI]) -> _nodes.Nodes: """ node_type = self.schema.node(node_type) # NOTE: Nodes constructor materializes guids. - return nodes.Nodes(self.__backend, self.__user, node_type, guids) + return _nodes.Nodes(self._backend, self._user, type_, guids) ## EOF ## diff --git a/bsfs/schema/__init__.py b/bsfs/schema/__init__.py index ce381ec..ad4d456 100644 --- a/bsfs/schema/__init__.py +++ b/bsfs/schema/__init__.py @@ -8,7 +8,6 @@ Author: Matthias Baumgartner, 2022 import typing # inner-module imports -#from . import types from .schema import Schema from .types import Literal, Node, Predicate @@ -18,7 +17,6 @@ __all__: typing.Sequence[str] = ( 'Node', 'Predicate', 'Schema', - #'types', ) ## EOF ## diff --git a/test/graph/test_graph.py b/test/graph/test_graph.py index 96046ef..eaeee0c 100644 --- a/test/graph/test_graph.py +++ b/test/graph/test_graph.py @@ -8,10 +8,10 @@ Author: Matthias Baumgartner, 2022 import unittest # bsie imports -from bsfs import schema as _schema +from bsfs import schema from bsfs.namespace import ns from bsfs.triple_store import SparqlStore -from bsfs.utils import URI +from bsfs.utils import URI, errors from bsfs.graph.nodes import Nodes # objects to test @@ -24,7 +24,7 @@ class TestGraph(unittest.TestCase): def setUp(self): self.user = URI('http://example.com/me') self.backend = SparqlStore.Open(None) - self.backend.schema = _schema.Schema.from_string(''' + self.backend.schema = schema.Schema.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix bsfs: <http://bsfs.ai/schema/> bsfs:Entity rdfs:subClassOf bsfs:Node . |