Skip to content

Commit

Permalink
fixes for turtle/trig namespace handling
Browse files Browse the repository at this point in the history
raise exception when trying to rebind a prefix to another ns.
fix broken rebinding when generating prefixes

This fixes #679 - but actually it's more like a work-around. The
underlying problem is confusion about context and graph objects (#167)
  • Loading branch information
gromgull committed Jan 24, 2017
1 parent 17abfb9 commit e641ca4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
5 changes: 4 additions & 1 deletion rdflib/plugins/serializers/turtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def __init__(self, store):
self.reset()

def addNamespace(self, prefix, uri):
if prefix in self.namespaces and self.namespaces[prefix]!=uri:
raise Exception("Trying to override namespace prefix %s => %s, but it's already bound to %s"%(prefix, uri, self.namespaces[prefix]))
self.namespaces[prefix] = uri

def checkSubject(self, subject):
Expand Down Expand Up @@ -195,7 +197,8 @@ def addNamespace(self, prefix, namespace):
p = "p" + p
self._ns_rewrite[prefix] = p

prefix = self._ns_rewrite.get(prefix, prefix)
prefix = self._ns_rewrite.get(prefix, prefix)

super(TurtleSerializer, self).addNamespace(prefix, namespace)
return prefix

Expand Down
2 changes: 1 addition & 1 deletion test/test_trig.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def testGraphParsing(self):

def testRoundTrips(self):

raise unittest.SkipTest('skipped until 5.0')
self.skipTest('skipped until 5.0')

data = """
<http://example.com/thing#thing_a> <http://example.com/knows> <http://example.com/thing#thing_b> .
Expand Down
23 changes: 0 additions & 23 deletions test/test_trig_export.py

This file was deleted.

0 comments on commit e641ca4

Please sign in to comment.