aboutsummaryrefslogtreecommitdiffstats
path: root/bsfs/graph/nodes.py
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-01-21 22:32:33 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-01-21 22:32:33 +0100
commit9310610a7edf4dcbb934aedcecff1d11348197bb (patch)
treee7d342d8f25ae40e6bdaf33549f7145bb8697f23 /bsfs/graph/nodes.py
parentc196d2ce73d8351a18c19bcddd4b06d224e644fc (diff)
downloadbsfs-9310610a7edf4dcbb934aedcecff1d11348197bb.tar.gz
bsfs-9310610a7edf4dcbb934aedcecff1d11348197bb.tar.bz2
bsfs-9310610a7edf4dcbb934aedcecff1d11348197bb.zip
nodes predicate walk sugar
Diffstat (limited to 'bsfs/graph/nodes.py')
-rw-r--r--bsfs/graph/nodes.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/bsfs/graph/nodes.py b/bsfs/graph/nodes.py
index a4ba45f..18ab30d 100644
--- a/bsfs/graph/nodes.py
+++ b/bsfs/graph/nodes.py
@@ -19,6 +19,7 @@ from bsfs.utils import errors, URI, typename
# inner-module imports
from . import ac
from . import result
+from . import walk
# exports
__all__: typing.Sequence[str] = (
@@ -87,6 +88,18 @@ class Nodes():
"""Return all node guids."""
return iter(self._guids)
+ @property
+ def schema(self) -> bsc.Schema:
+ """Return the store's local schema."""
+ return self._backend.schema
+
+ def __getattr__(self, name: str):
+ try:
+ return super().__getattr__(name) # type: ignore [misc] # parent has no getattr
+ except AttributeError:
+ pass
+ return walk.Walk(self, walk.Walk.step(self.schema, self.node_type, name))
+
def set(
self,
pred: URI, # FIXME: URI or bsc.Predicate?
@@ -141,7 +154,7 @@ class Nodes():
if view not in (dict, list):
raise ValueError(f'expected dict or list, found {view}')
# process paths: create fetch ast, build name mapping, and find unique paths
- schema = self._backend.schema
+ schema = self.schema
statements = set()
name2path = {}
unique_paths = set() # paths that result in a single (unique) value