comparison planemo/lib/python3.7/site-packages/rdflib/serializer.py @ 1:56ad4e20f292 draft

"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author guerler
date Fri, 31 Jul 2020 00:32:28 -0400
parents
children
comparison
equal deleted inserted replaced
0:d30785e31577 1:56ad4e20f292
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