

def parse(self, source, graph, encoding='utf-8'):
    if (encoding not in [None, 'utf-8']):
        raise Exception((('TriG files are always utf-8 encoded, ', 'I was passed: %s') % encoding))
    assert graph.store.context_aware, 'TriG Parser needs a context-aware store!'
    conj_graph = ConjunctiveGraph(store=graph.store)
    conj_graph.default_context = graph
    conj_graph.namespace_manager = graph.namespace_manager
    sink = RDFSink(conj_graph)
    baseURI = conj_graph.absolutize((source.getPublicId() or source.getSystemId() or ''))
    p = TrigSinkParser(sink, baseURI=baseURI, turtle=True)
    p.loadStream(source.getByteStream())
    for (prefix, namespace) in p._bindings.items():
        conj_graph.bind(prefix, namespace)

dataset/ETHPy150Open RDFLib/rdflib/rdflib/plugins/parsers/trig.py TrigParser.parse/original