comparison env/lib/python3.7/site-packages/rdflib/plugins/parsers/nt.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
1 from rdflib.parser import Parser
2 from rdflib.plugins.parsers.ntriples import NTriplesParser
3
4 __all__ = ['NTSink', 'NTParser']
5
6
7 class NTSink(object):
8 def __init__(self, graph):
9 self.graph = graph
10
11 def triple(self, s, p, o):
12 self.graph.add((s, p, o))
13
14
15 class NTParser(Parser):
16 """parser for the ntriples format, often stored with the .nt extension
17
18 See http://www.w3.org/TR/rdf-testcases/#ntriples"""
19
20 def __init__(self):
21 super(NTParser, self).__init__()
22
23 def parse(self, source, sink, baseURI=None):
24 f = source.getByteStream() # TODO getCharacterStream?
25 parser = NTriplesParser(NTSink(sink))
26 parser.parse(f)
27 f.close()