owmeta_core.rdf_type_resolver module

class owmeta_core.rdf_type_resolver.RDFTypeResolver(default_type, type_resolver, id2object_translator, deserializer)[source]

Bases: object

Handles mapping between RDF graphs and Python types

Parameters
default_typestr, rdflib.term.URIRef

If no type is retrieved from the graph, this will be the type selected

type_resolvercallable()(rdflib.graph.Graph, [rdflib.term.URIRef], rdflib.term.URIRef or None) -> rdflib.term.URIRef

This callable (e.g., function) receives a graph, all the types found for an identifier, and the “base” type sought, which constrains the result to be a sub-type of the base, and returns a single identifier for a type that id2object_translator can translate into an object

id2object_translatorcallable()(rdflib.term.URIRef, rdflib.term.URIRef, owmeta_core.context.Context) -> object

This callable (e.g., function) receives an identifier for an object and an identifier for the object’s type and returns an object corresponding to the identifier and type

deserializercallable()(rdflib.term.Literal) -> object

This callable (e.g., function) receives a literal and turns it into an object