comparison env/lib/python3.9/site-packages/rdflib/serializer.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
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