self, destination=None, encoding="utf-8", format='xml', **args): |
|
if self.type in ('CONSTRUCT', 'DESCRIBE'): |
return self.graph.serialize( |
destination, encoding=encoding, format=format, **args) |
|
"""stolen wholesale from graph.serialize""" |
from rdflib import plugin |
serializer = plugin.get(format, ResultSerializer)(self) |
if destination is None: |
stream = BytesIO() |
stream2 = EncodeOnlyUnicode(stream) |
serializer.serialize(stream2, encoding=encoding, **args) |
return stream.getvalue() |
if hasattr(destination, "write"): |
stream = destination |
serializer.serialize(stream, encoding=encoding, **args) |
else: |
location = destination |
scheme, netloc, path, params, query, fragment = urlparse(location) |
if netloc != "": |
print("WARNING: not saving as location" + |
"is not a local file reference") |
return |
fd, name = tempfile.mkstemp() |
stream = os.fdopen(fd, 'wb') |
serializer.serialize(stream, encoding=encoding, **args) |