Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions rdflib/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ def bind(self, prefix, namespace, override=True):
if prefix is None:
prefix = ''
bound_namespace = self.store.namespace(prefix)
# Check if the bound_namespace contains a URI
# and if so convert it into a URIRef for comparison
# This is to prevent duplicate namespaces with the
# same URI
if bound_namespace:
bound_namespace = URIRef(bound_namespace)
if bound_namespace and bound_namespace != namespace:
# prefix already in use for different namespace
#
Expand All @@ -361,6 +367,11 @@ def bind(self, prefix, namespace, override=True):
num = 1
while 1:
new_prefix = "%s%s" % (prefix, num)
tnamespace = self.store.namespace(new_prefix)
if tnamespace and namespace == URIRef(tnamespace):
# the prefix is already bound to the correct
# namespace
return
if not self.store.namespace(new_prefix):
break
num += 1
Expand Down