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 58da409 commit 8447c3d
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit 8447c3d

Please sign in to comment.