diff options
| author | Niklas Lindström <lindstream@gmail.com> | 2016-08-04 14:30:41 +0200 |
|---|---|---|
| committer | Niklas Lindström <lindstream@gmail.com> | 2016-08-04 14:30:41 +0200 |
| commit | fbf95a8ea506f95394c36a09241448e6900fbd77 (patch) | |
| tree | 31d49cc0a24e98ab78a8281eae2fd760ad0ad554 | |
| parent | 89d1761db878824be0c40b1e358b58962320665e (diff) | |
| download | rdflib-fbf95a8ea506f95394c36a09241448e6900fbd77.tar.gz | |
Set identifier of the parser sink to target graph. Fixes #432.
| -rw-r--r-- | rdflib/plugins/parsers/trig.py | 2 | ||||
| -rw-r--r-- | test/test_issue432.py | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/rdflib/plugins/parsers/trig.py b/rdflib/plugins/parsers/trig.py index 37cc9a84..34a13455 100644 --- a/rdflib/plugins/parsers/trig.py +++ b/rdflib/plugins/parsers/trig.py @@ -146,7 +146,7 @@ class TrigParser(Parser): # 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 diff --git a/test/test_issue432.py b/test/test_issue432.py new file mode 100644 index 00000000..9ac4ec00 --- /dev/null +++ b/test/test_issue432.py @@ -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 |
