hydra.rdf.utils module

Utility functions for working with RDF graphs and descriptions.

hydra.rdf.utils.descriptions_to_graph(ds: Sequence[Description]) Graph

Convert a list of descriptions to an RDF graph.

hydra.rdf.utils.empty_description(node: Node_) Description

Create an empty description with a given node.

hydra.rdf.utils.empty_lang_strings() LangStrings

An empty LangStrings value.

hydra.rdf.utils.empty_rdf_graph() Graph

An empty RDF graph.

hydra.rdf.utils.encode_literal(lit: Literal) Literal

Encode a Hydra literal as an RDF literal.

hydra.rdf.utils.for_objects(subj: Resource, pred: Iri, objs: Sequence[Node_]) Sequence[Triple]

Create triples from a subject, predicate, and list of object nodes.

hydra.rdf.utils.iri(ns: str, local: str) Iri

Construct an IRI from a namespace and local name.

hydra.rdf.utils.key_iri(local: str) Iri

Construct a key IRI from a local name.

hydra.rdf.utils.merge_graphs(graphs: Sequence[Graph]) Graph

Merge a list of RDF graphs into a single graph.

hydra.rdf.utils.name_to_iri(name: Name) Iri

Convert a Hydra name to an RDF IRI.

hydra.rdf.utils.next_blank_node(counter: int) tuple[Resource, int]

Generate the next blank node and an incremented counter.

hydra.rdf.utils.property_iri(rname: Name, fname: Name) Iri

Construct a property IRI from a record name and field name.

hydra.rdf.utils.rdf_iri(local: str) Iri

Construct an RDF namespace IRI.

hydra.rdf.utils.resource_to_node(r: Resource) Node_

Convert a resource to a node.

hydra.rdf.utils.subjects_of(descs: Sequence[Description]) Sequence[Node_]

Extract subjects from a list of descriptions.

hydra.rdf.utils.triples_of(descs: Sequence[Description]) Sequence[Triple]

Extract all triples from a list of descriptions.

hydra.rdf.utils.xml_schema_datatype_iri(local: str) Iri

Construct an XML Schema datatype IRI.