Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/rdflib/plugins/parsers/nt.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
| author | shellac |
|---|---|
| date | Sat, 02 May 2020 07:14:21 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:26e78fe6e8c4 |
|---|---|
| 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() |
