git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into senslab2
[sfa.git]
/
sfa
/
util
/
xrn.py
diff --git
a/sfa/util/xrn.py
b/sfa/util/xrn.py
index
c9c8db0
..
08a257d
100644
(file)
--- a/
sfa/util/xrn.py
+++ b/
sfa/util/xrn.py
@@
-22,7
+22,7
@@
#----------------------------------------------------------------------
import re
#----------------------------------------------------------------------
import re
-
+import sys
from sfa.util.faults import SfaAPIError
# for convenience and smoother translation - we should get rid of these functions eventually
from sfa.util.faults import SfaAPIError
# for convenience and smoother translation - we should get rid of these functions eventually
@@
-93,11
+93,12
@@
class Xrn:
return False
########## basic tools on URNs
return False
########## basic tools on URNs
- URN_PREFIX = "urn:publicid:idn"
+ URN_PREFIX = "urn:publicid:IDN"
+ URN_PREFIX_lower = "urn:publicid:idn"
@staticmethod
def is_urn (text):
@staticmethod
def is_urn (text):
- return text.lower().startswith(Xrn.URN_PREFIX)
+ return text.lower().startswith(Xrn.URN_PREFIX
_lower
)
@staticmethod
def urn_full (urn):
@staticmethod
def urn_full (urn):
@@
-120,6
+121,7
@@
class Xrn:
# provide either urn, or (hrn + type)
def __init__ (self, xrn, type=None):
if not xrn: xrn = ""
# provide either urn, or (hrn + type)
def __init__ (self, xrn, type=None):
if not xrn: xrn = ""
+
# user has specified xrn : guess if urn or hrn
if Xrn.is_urn(xrn):
self.hrn=None
# user has specified xrn : guess if urn or hrn
if Xrn.is_urn(xrn):
self.hrn=None
@@
-153,7
+155,8
@@
class Xrn:
# self.authority keeps a list
if not hasattr(self,'authority'):
self.authority=Xrn.hrn_auth_list(self.hrn)
# self.authority keeps a list
if not hasattr(self,'authority'):
self.authority=Xrn.hrn_auth_list(self.hrn)
-
+
+
def get_leaf(self):
self._normalize()
return self.leaf
def get_leaf(self):
self._normalize()
return self.leaf
@@
-222,17
+225,21
@@
class Xrn:
raise SfaAPIError, "Xrn.hrn_to_urn, hrn=%s"%self.hrn
if self.type and self.type.startswith('authority'):
raise SfaAPIError, "Xrn.hrn_to_urn, hrn=%s"%self.hrn
if self.type and self.type.startswith('authority'):
- self.authority = Xrn.hrn_split(self.hrn)
+ self.authority = Xrn.hrn_auth_list(self.hrn)
+ leaf = self.get_leaf()
+ #if not self.authority:
+ # self.authority = [self.hrn]
type_parts = self.type.split("+")
self.type = type_parts[0]
name = 'sa'
if len(type_parts) > 1:
name = type_parts[1]
type_parts = self.type.split("+")
self.type = type_parts[0]
name = 'sa'
if len(type_parts) > 1:
name = type_parts[1]
+ auth_parts = [part for part in [self.get_authority_urn(), leaf] if part]
+ authority_string = ":".join(auth_parts)
else:
self.authority = Xrn.hrn_auth_list(self.hrn)
name = Xrn.hrn_leaf(self.hrn)
else:
self.authority = Xrn.hrn_auth_list(self.hrn)
name = Xrn.hrn_leaf(self.hrn)
-
- authority_string = self.get_authority_urn()
+ authority_string = self.get_authority_urn()
if self.type == None:
urn = "+".join(['',authority_string,Xrn.unescape(name)])
if self.type == None:
urn = "+".join(['',authority_string,Xrn.unescape(name)])