Skip to content

Commit

Permalink
Serializers: Directly use oxigraph for dump
Browse files Browse the repository at this point in the history
An error in `isinstance` was breaking this feature
  • Loading branch information
Tpt committed Oct 27, 2024
1 parent ba37723 commit f7b1bf1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions oxrdflib/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit f7b1bf1

Please sign in to comment.