Skip to content

Commit

Permalink
Merge pull request #536 from pchampin/fix-issue-535
Browse files Browse the repository at this point in the history
fixed issue #535
  • Loading branch information
joernhees committed Nov 28, 2015
2 parents e261af3 + 561d327 commit c956493
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rdflib/plugins/parsers/nquads.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def parse(self, inputsource, sink, **kwargs):
"""Parse f as an N-Triples file."""
assert sink.store.context_aware, ("NQuadsParser must be given"
" a context aware store.")
self.sink = ConjunctiveGraph(store=sink.store)
self.sink = ConjunctiveGraph(store=sink.store, identifier=sink.identifier)

source = inputsource.getByteStream()

Expand Down Expand Up @@ -81,7 +81,7 @@ def parseline(self):
obj = self.object()
self.eat(r_wspace)

context = self.uriref() or self.nodeid()
context = self.uriref() or self.nodeid() or self.sink.identifier
self.eat(r_tail)

if self.line:
Expand Down
19 changes: 19 additions & 0 deletions test/test_issue535.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from rdflib import ConjunctiveGraph, URIRef
from rdflib.parser import StringInputSource

def test_nquads_default_graph():
ds = ConjunctiveGraph()

data = """
<http://example.org/s1> <http://example.org/p1> <http://example.org/o1> .
<http://example.org/s2> <http://example.org/p2> <http://example.org/o2> .
<http://example.org/s3> <http://example.org/p3> <http://example.org/o3> <http://example.org/g3> .
"""

publicID = URIRef("http://example.org/g0")

ds.parse(data=data, format="nquads", publicID=publicID)

assert len(ds) == 3, len(g)
assert len(list(ds.contexts())) == 2, len(list(ds.contexts()))
assert len(ds.get_context(publicID)) == 2, len(ds.get_context(publicID))

0 comments on commit c956493

Please sign in to comment.