Created
February 28, 2011 10:50
-
-
Save slok/847177 to your computer and use it in GitHub Desktop.
patch for raptor(redland) python bindings: adds seralization from stream to string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /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