owmeta_core.rdf_utils module¶
- class owmeta_core.rdf_utils.BatchAddGraph(graph, batchsize=1000, _parent=None, *args, **kwargs)[source]¶
Bases:
object
Wrapper around graph that turns calls to ‘add’ into calls to ‘addN’
- owmeta_core.rdf_utils.transitive_lookup(graph, start, predicate, context=None, direction='down', seen=None)[source]¶
Do a transitive lookup over an
rdflib.graph.Graph
orrdflib.store.Store
In other words, finds all resources which relate to
start
through zero or morepredicate
relationships.start
itself will be included in the return value.Loops in the input
graph
will not cause non-termination.- Parameters
- graph
rdflib.graph.Graph
orrdflib.store.Store
The graph to query
- start
rdflib.term.Identifier
The resource in the graph to start from
- predicate
rdflib.term.URIRef
The predicate relating terms in the closure
- context
rdflib.graph.Graph
orrdflib.term.URIRef
The context in which the query should run. Optional
- direction
DOWN
orUP
The direction in which to traverse
- seen
set
of
rdflib.term.Identifier
A set of terms which have already been “seen” by the algorithm. Useful for repeated calls to
transitive_lookup
. Note: if thestart
is inseen
, queries fromstart
will still be done, but any items in the result of those queries will not be queried for if inseen
. Optional
- graph
- Returns
set
of
rdflib.term.Identifier
resources in the transitive closure of
predicate
fromstart
- owmeta_core.rdf_utils.transitive_subjects(graph, start, predicate, context=None, direction='down', seen=None)¶
Alias to
transitive_lookup
- owmeta_core.rdf_utils.DOWN = 'down'¶
Subject to Object direction for traversal across triples.
- owmeta_core.rdf_utils.UP = 'up'¶
Object to Subject direction for traversal across triples.