From f7b1bf19865d105dcf5b0db75f486c3b1ce8ec4e Mon Sep 17 00:00:00 2001 From: Thomas Tanon Date: Sun, 27 Oct 2024 19:09:36 +0100 Subject: [PATCH] Serializers: Directly use oxigraph for dump An error in `isinstance` was breaking this feature --- oxrdflib/serializer.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/oxrdflib/serializer.py b/oxrdflib/serializer.py index a151746..1411206 100644 --- a/oxrdflib/serializer.py +++ b/oxrdflib/serializer.py @@ -2,6 +2,7 @@ from typing import IO, Any, Optional from pyoxigraph import RdfFormat, serialize +from rdflib import Dataset from rdflib.serializer import Serializer from oxrdflib._converter import to_ox @@ -28,8 +29,12 @@ def serialize( if encoding not in (None, "utf-8"): raise ValueError(f"RDF files are always utf-8 encoded, I was passed: {encoding}") # TODO: base and prefixes - if isinstance(self.store, OxigraphStore): - self.store._inner.dump(stream, format=self._format) + if isinstance(self.store.store, OxigraphStore): + self.store.store._inner.dump( + stream, + format=self._format, + from_graph=None if isinstance(self.store, Dataset) else to_ox(self.store.identifier), + ) else: serialize((to_ox(q) for q in self.store), stream, format=self._format)