util
RDF4J utility functions.
Functions:
-
build_context_param–Build the RDF4J http context query parameters dictionary.
-
build_infer_param–Build the RDF4J http infer query parameters dictionary.
-
build_sparql_query_accept_header–Build the SPARQL query accept header.
-
build_spo_param–Build the RDF4J http subj, predicate, and object query parameters dictionary.
-
rdf_payload_to_stream–Convert an RDF payload into a file-like object.
-
validate_graph_name– -
validate_no_bnodes–Validate that the subject, predicate, and object are not BNodes.
build_context_param
build_context_param(params: dict[str, str], graph_name: IdentifiedNode | Iterable[IdentifiedNode] | str | None = None) -> None
Build the RDF4J http context query parameters dictionary.
Note
This mutates the params dictionary key context.
Parameters:
-
(paramsdict[str, str]) –The
httpx.Requestparameter dictionary. -
(graph_nameIdentifiedNode | Iterable[IdentifiedNode] | str | None, default:None) –The graph name or iterable of graph names.
This is the
contextquery parameter value.
Source code in rdflib/contrib/rdf4j/util.py
build_infer_param
Build the RDF4J http infer query parameters dictionary.
Note
This mutates the params dictionary key infer.
Parameters:
-
(paramsdict[str, str]) –The
httpx.Requestparameter dictionary. -
(inferbool, default:True) –The
inferquery parameter value.
Source code in rdflib/contrib/rdf4j/util.py
build_sparql_query_accept_header
build_sparql_query_accept_header(query: str, headers: dict[str, str])
Build the SPARQL query accept header.
Note
This mutates the headers dictionary key Accept.
Parameters:
-
(querystr) –The SPARQL query.
Source code in rdflib/contrib/rdf4j/util.py
build_spo_param
build_spo_param(params: dict[str, str], subj: SubjectType = None, pred: PredicateType = None, obj: ObjectType = None) -> None
Build the RDF4J http subj, predicate, and object query parameters dictionary.
Note
This mutates the params dictionary key subj, pred, and obj.
Parameters:
-
(paramsdict[str, str]) –The
httpx.Requestparameter dictionary. -
(subjSubjectType, default:None) –The
subjquery parameter value. -
(predPredicateType, default:None) –The
predquery parameter value. -
(objObjectType, default:None) –The
objquery parameter value.
Source code in rdflib/contrib/rdf4j/util.py
rdf_payload_to_stream
Convert an RDF payload into a file-like object.
Parameters:
Returns:
-
BinaryIO–A tuple containing the file-like object and a boolean indicating whether the
-
bool–immediate caller should close the stream.
Source code in rdflib/contrib/rdf4j/util.py
validate_graph_name
Source code in rdflib/contrib/rdf4j/util.py
validate_no_bnodes
validate_no_bnodes(subj: SubjectType, pred: PredicateType, obj: ObjectType, graph_name: URIRef | Iterable[URIRef] | str | None) -> None
Validate that the subject, predicate, and object are not BNodes.