middleware.common ================= .. py:module:: middleware.common .. autoapi-nested-parse:: Small shared helpers for middleware implementations. Functions --------- .. autoapisummary:: middleware.common.copy_graph middleware.common.copy_dataset middleware.common.not_none Module Contents --------------- .. py:function:: copy_graph(source_graph: rdflib.Graph) -> rdflib.Graph Return an new copy of a graph in ``O(triples)`` time. The new graph is backed by a :class:`rdflib.plugins.stores.memory.Memory` store. Be aware of the size of your ``source_graph`` before invoking this function. Aside from the store, the returned graph replicates all of the source graph's properties: namespace bindings, base URI, identifier, and triples. .. py:function:: copy_dataset(source_dataset: rdflib.Dataset) -> rdflib.Dataset Return an new copy of a dataset in ``O(quads)`` time. The new dataset is backed by a :class:`rdflib.plugins.stores.memory.Memory` store. Be aware of the size of your ``source_dataset`` before invoking this function. Aside from the store, the returned dataset replicates all of the source dataset's properties: namespace bindings, default graph base URI, and quads. .. py:function:: not_none[T](value: T | None, message: str = 'Value cannot be None') -> T Return ``value`` or raise ``ValueError`` when it is ``None``.