Skip to content

Commit

Permalink
Set identifier of the parser sink to target graph. Fixes #432.
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasl committed Aug 4, 2016
1 parent 89d1761 commit fbf95a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rdflib/plugins/parsers/trig.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def parse(self, source, graph, encoding="utf-8"):
# we're currently being handed a Graph, not a ConjunctiveGraph
assert graph.store.context_aware, "TriG Parser needs a context-aware store!"

conj_graph = ConjunctiveGraph(store=graph.store)
conj_graph = ConjunctiveGraph(store=graph.store, identifier=graph.identifier)
conj_graph.default_context = graph # TODO: CG __init__ should have a
# default_context arg
# TODO: update N3Processor so that it can use conj_graph as the sink
Expand Down
17 changes: 17 additions & 0 deletions test/test_issue432.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import rdflib

def test_trig_default_graph():
ds = rdflib.ConjunctiveGraph()
data = """
@prefix : <http://example.com/> .
<> <b> <c> .
{ <d> <e> <f> . }
<g1> { <d> <e> <f> . }
<g2> { <g> <h> <i> . }
"""
ds.parse(data=data, format='trig', publicID=ds.default_context.identifier)

assert len(list(ds.contexts())) == 3
assert len(list(ds.default_context)) == 2

0 comments on commit fbf95a8

Please sign in to comment.