Skip to content

Instantly share code, notes, and snippets.

@slok
Created February 28, 2011 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slok/847177 to your computer and use it in GitHub Desktop.
Save slok/847177 to your computer and use it in GitHub Desktop.
patch for raptor(redland) python bindings: adds seralization from stream to string
--- /usr/lib64/python2.6/site-packages/RDF.py.original 2011-02-28 11:32:55.235000011 -0100
+++ /usr/lib64/python2.6/site-packages/RDF.py 2011-02-28 11:33:03.555000011 -0100
@@ -2283,7 +2283,19 @@
else:
rbase_uri = None
return Redland.librdf_serializer_serialize_model_to_string(self._serializer, rbase_uri, model._model)
-
+
+ def serialize_stream_to_string(self, stream, base_uri=None):
+ """Serialize to a string using the optional base URI."""
+ if type(base_uri) is str:
+ base_uri = Uri(string = base_uri)
+ elif type(base_uri) is unicode:
+ import Redland_python
+ base_uri = Uri(string=Redland_python.unicode_to_bytes(base_uri))
+ if base_uri is not None:
+ rbase_uri = base_uri._reduri
+ else:
+ rbase_uri = None
+ return Redland.librdf_serializer_serialize_stream_to_string(self._serializer, rbase_uri, stream._stream)
# TODO: features could usefully be implemented as a collection
def get_feature(self, uri):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment