owmeta_core.rdf_query_util module¶
- exception owmeta_core.rdf_query_util.MissingRDFTypeException[source]¶
Bases:
Exception
Raised when we were looking for an RDF type couldn’t find one
- owmeta_core.rdf_query_util.get_most_specific_rdf_type(graph, types, base=None)[source]¶
Find the RDF type that isn’t a sub-class of any other, constrained to be a sub-class of
base
if that is provided.- Parameters
- graph
rdflib.graph.Graph
The graph to query rdfs:subClassOf relationships
- types
list
of
rdflib.term.URIRef
The types to query
- base
rdflib.term.URIRef
The “base” type
- graph
See also
RDFTypeResolver
- owmeta_core.rdf_query_util.load(graph, start, target_type, *args)[source]¶
Loads a set of objects based on the graph starting from
start
- Parameters
- graph
rdflib.graph.Graph
The graph to query from
- start
graph_object.GraphObject
The graph object to start the query from
- target_type
rdflib.term.URIRef
URI of the target type. Any result will be a sub-class of this type
- graph
- owmeta_core.rdf_query_util.load_base(graph, idents, target_type, context, resolver)[source]¶
Loads a set of objects from an RDF graph given their identifiers
- Parameters
- graph
rdflib.graph.Graph
The graph to query from
- idents
list
of
rdflib.term.URIRef
A list of identifiers to convert into objects
- target_type
rdflib.term.URIRef
URI of the target type. Any result will be a sub-class of this type
- context
object
Limits the scope of the query to statements within or entailed by this context. Notionally, it’s a owmeta_core.context.Context instance
- resolver
rdf_type_resolver.RDFTypeResolver
Handles some of the mappings
- graph
- owmeta_core.rdf_query_util.load_terms(graph, start, target_type)[source]¶
Loads a set of terms based on the object graph starting from
start
- Parameters
- graph
rdflib.graph.Graph
The graph to query from
- start
graph_object.GraphObject
The graph object to start the query from
- target_type
rdflib.term.URIRef
URI of the target type. Any result will be a sub-class of this type
- graph
- owmeta_core.rdf_query_util.oid(identifier_or_rdf_type, rdf_type, context, base_type=None)[source]¶
Create an object from its rdf type
- Parameters
- identifier_or_rdf_type
rdflib.term.URIRef
If
rdf_type
is provided, then this value is used as the identifier for the newly created object. Otherwise, this value will be therdf_type
of the object used to determine the Python type and the object’s identifier will be randomly generated.- rdf_type
rdflib.term.URIRef
If provided, this will be the
rdf_type
of the newly created object.- context
Context
,optional
The context to resolve a class from
- base_type
type
The base type
- identifier_or_rdf_type
- Returns
The
newly
created
object