Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/rdflib/plugins/parsers/nt.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 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() |