apis_core.utils.rdf#

Module Contents#

Classes#

Functions#

resolve

Look at the value of object and return the parsed value. If the value starts and ens with angle brackets, we interpret it as and transform it to an URI. If the value is simple text we interpret it as an curie and we expand it using the graphs namespace manager. Otherwise we simply return the value

load_path

Load a tomlfile either from a path or from the directory triple_configs in any of the app directories.

graph_matches_config

Check if a file contains a config that matches this graph and if so, return the config as dict. Otherwise return False

build_sparql_query

Build a SPARQL query with language preferences.

get_value_graph

load_uri_using_path

Data#

API#

apis_core.utils.rdf.logger = 'getLogger(...)'#
class apis_core.utils.rdf.Attribute[source]#
value: Union[str | list[str]] = None#
class apis_core.utils.rdf.Relation[source]#
name: str = None#
value: Dict[str, str] = None#
class apis_core.utils.rdf.Filter[source]#
value: List[typing.Tuple[str:str]] = None#
apis_core.utils.rdf.resolve(obj, graph)[source]#

Look at the value of object and return the parsed value. If the value starts and ens with angle brackets, we interpret it as and transform it to an URI. If the value is simple text we interpret it as an curie and we expand it using the graphs namespace manager. Otherwise we simply return the value

apis_core.utils.rdf.load_path(path: str | pathlib.Path) → dict[source]#

Load a tomlfile either from a path or from the directory triple_configs in any of the app directories.

apis_core.utils.rdf.graph_matches_config(graph: rdflib.Graph, configfile: pathlib.Path) → dict[source]#

Check if a file contains a config that matches this graph and if so, return the config as dict. Otherwise return False

apis_core.utils.rdf.build_sparql_query(curie: str) → str[source]#

Build a SPARQL query with language preferences.

Args:
curie: predicate to filter on as defined in the toml.

needs to include the predicate and optionally a lang tag to filter for separated with a comma. Eg β€œwdt:P122,en”.

Returns:

A SPARQL query string

apis_core.utils.rdf.get_value_graph(graph: rdflib.Graph, curies: str | list[str]) → list[source]#
apis_core.utils.rdf.load_uri_using_path(uri, configfile: pathlib.Path | str) → dict[source]#