comparison env/lib/python3.7/site-packages/rdflib/serializer.py @ 0:26e78fe6e8c4 draft

"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author shellac
date Sat, 02 May 2020 07:14:21 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:26e78fe6e8c4
1 """
2 Serializer plugin interface.
3
4 This module is useful for those wanting to write a serializer that can
5 plugin to rdflib. If you are wanting to invoke a serializer you likely
6 want to do so through the Graph class serialize method.
7
8 TODO: info for how to write a serializer that can plugin to rdflib.
9 See also rdflib.plugin
10
11 """
12
13 from rdflib.term import URIRef
14
15 __all__ = ['Serializer']
16
17
18 class Serializer(object):
19
20 def __init__(self, store):
21 self.store = store
22 self.encoding = "UTF-8"
23 self.base = None
24
25 def serialize(self, stream, base=None, encoding=None, **args):
26 """Abstract method"""
27
28 def relativize(self, uri):
29 base = self.base
30 if base is not None and uri.startswith(base):
31 uri = URIRef(uri.replace(base, "", 1))
32 return uri