comparison env/lib/python3.7/site-packages/rdflib/serializer.py @ 2:6af9afd405e9 draft

"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author shellac
date Thu, 14 May 2020 14:56:58 -0400
parents 26e78fe6e8c4
children
comparison
equal deleted inserted replaced
1:75ca89e9b81c 2:6af9afd405e9
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