aboutsummaryrefslogtreecommitdiffstats
path: root/bsfs/graph/resolve.py
diff options
context:
space:
mode:
Diffstat (limited to 'bsfs/graph/resolve.py')
-rw-r--r--bsfs/graph/resolve.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/bsfs/graph/resolve.py b/bsfs/graph/resolve.py
index 4677401..a58eb67 100644
--- a/bsfs/graph/resolve.py
+++ b/bsfs/graph/resolve.py
@@ -1,9 +1,4 @@
-"""
-Part of the BlackStar filesystem (bsfs) module.
-A copy of the license is provided with the project.
-Author: Matthias Baumgartner, 2022
-"""
# imports
import typing
@@ -32,16 +27,30 @@ class Filter():
input: Any(ns.bse.tag, Is(Nodes(...)))
output: Any(ns.bse.tag, Or(Is(...), Is(...), ...)))
- >>> tags = graph.node(ns.bsfs.Tag, 'http://example.com/me/tag#1234')
- >>> graph.get(ns.bsfs.Entity, ast.filter.Any(ns.bse.tag, ast.filter.Is(tags)))
+ >>> tags = graph.node(ns.bsn.Tag, 'http://example.com/me/tag#1234')
+ >>> graph.get(ns.bsn.Entity, ast.filter.Any(ns.bse.tag, ast.filter.Is(tags)))
"""
def __init__(self, schema):
self.schema = schema
- def __call__(self, root_type: bsc.Node, node: ast.filter.FilterExpression):
- # FIXME: node can be None!
+ def __call__(
+ self,
+ root_type: bsc.Node,
+ node: typing.Optional[ast.filter.FilterExpression],
+ ):
+ """Alias for `Resolve.resolve`."""
+ return self.resolve(root_type, node)
+
+ def resolve(
+ self,
+ root_type: bsc.Node,
+ node: typing.Optional[ast.filter.FilterExpression],
+ ):
+ """Resolve Nodes instances of a *node* query starting at *root_type*."""
+ if node is None:
+ return None
return self._parse_filter_expression(root_type, node)
def _parse_filter_expression(