- authority = get_authority(hrn)
- name = get_leaf(hrn)
- urn = "+".join([unicode(part).replace('.', ':') \
- for part in ['',authority,type,name]])
+ if type == 'authority':
+ authority = hrn
+ name = 'sa'
+ else:
+ authority = get_authority(hrn)
+ name = get_leaf(hrn)
+
+ # We have to do the following conversion
+ # '\\.' -> '.' # where '.' belongs in the urn name
+ # '.' -> ':" # where ':' is the urn hierarchy delimiter
+ # by doing the following
+ # 1. split authority around '\\.'
+ # 2. replace '.' with ':' in all parts
+ # 3. join parts around '.'
+ parts = authority.split('\\.')
+ authority = '.'.join([part.replace('.', ':') for part in parts])
+
+ if type == None:
+ urn = "+".join(['',authority,name])
+ else:
+ urn = "+".join(['',authority,type,name])