<s> """<STR_LIT>""" <EOL> from codecs import getreader <EOL> from rdflib . py3compat import b <EOL> from rdflib import ConjunctiveGraph <EOL> from rdflib . plugins . parsers . ntriples import NTriplesParser <EOL> from rdflib . plugins . parsers . ntriples import ParseError <EOL> from rdflib . plugins . parsers . ntriples import r_tail <EOL> from rdflib . plugins . parsers . ntriples import r_wspace <EOL> from rdflib . plugins . parsers . ntriples import r_wspaces <EOL> __all__ = [ '<STR_LIT>' ] <EOL> class NQuadsParser ( NTriplesParser ) : <EOL> def parse ( self , inputsource , sink , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> assert sink . store . context_aware , ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . sink = ConjunctiveGraph ( store = sink . store , identifier = sink . identifier ) <EOL> source = inputsource . getByteStream ( ) <EOL> if not hasattr ( source , '<STR_LIT>' ) : <EOL> raise ParseError ( "<STR_LIT>" ) <EOL> source = getreader ( '<STR_LIT:utf-8>' ) ( source ) <EOL> self . file = source <EOL> self . buffer = '<STR_LIT>' <EOL> while True : <EOL> self . line = __line = self . readline ( ) <EOL> if self . line is None : <EOL> break <EOL> try : <EOL> self . parseline ( ) <EOL> except ParseError , msg : <EOL> raise ParseError ( "<STR_LIT>" % ( msg , __line ) ) <EOL> return self . sink <EOL> def parseline ( self ) : <EOL> self . eat ( r_wspace ) <EOL> if ( not self . line ) or self . line . startswith ( ( '<STR_LIT:#>' ) ) : <EOL> return <EOL> subject = self . subject ( ) <EOL> self . eat ( r_wspace ) <EOL> predicate = self . predicate ( ) <EOL> self . eat ( r_wspace ) <EOL> obj = self . object ( ) <EOL> self . eat ( r_wspace ) <EOL> context = self . uriref ( ) or self . nodeid ( ) or self . sink . identifier <EOL> self . eat ( r_tail ) <EOL> if self . line : <EOL> raise ParseError ( "<STR_LIT>" ) <EOL> self . sink . get_context ( context ) . add ( ( subject , predicate , obj ) ) </s>
