X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fxrn.py;h=26795129f3da501a8d211b96b6ceb0c121df3649;hb=b8596ce95578bf77158db2a5dacbaab36bdf6b16;hp=1f50628907a1098ac145ae5d10a4aab1850e07d1;hpb=57b6a99255d4a88be9c0f910f8524677e34ff4bc;p=sfa.git diff --git a/sfa/util/xrn.py b/sfa/util/xrn.py index 1f506289..26795129 100644 --- a/sfa/util/xrn.py +++ b/sfa/util/xrn.py @@ -22,7 +22,7 @@ #---------------------------------------------------------------------- import re - +import sys from sfa.util.faults import SfaAPIError # for convenience and smoother translation - we should get rid of these functions eventually @@ -116,16 +116,19 @@ class 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.startswith(Xrn.URN_PREFIX): self.hrn=None self.urn=xrn self.urn_to_hrn() + #print>>sys.stderr, " \r\n \r\n \t XRN.PY init xrn.startswith(Xrn.URN_PREFIX) hrn %s urn %s type %s" %( self.hrn, self.urn, self.type) else: self.urn=None self.hrn=xrn self.type=type self.hrn_to_urn() + #print>>sys.stderr, " \r\n \r\n \t XRN.PY init ELSE hrn %s urn %s type %s" %( self.hrn, self.urn, self.type) # happens all the time .. # if not type: # debug_logger.debug("type-less Xrn's are not safe") @@ -136,13 +139,16 @@ class Xrn: def get_hrn_type(self): return (self.hrn, self.type) def _normalize(self): + #print>>sys.stderr, " \r\n \r\n \t XRN.PY _normalize self.hrn %s ",self.hrn if self.hrn is None: raise SfaAPIError, "Xrn._normalize" if not hasattr(self,'leaf'): self.leaf=Xrn.hrn_split(self.hrn)[-1] # self.authority keeps a list if not hasattr(self,'authority'): self.authority=Xrn.hrn_auth_list(self.hrn) - + #print>>sys.stderr, " \r\n \r\n \t XRN.PY _normalize self.hrn %s leaf %s authority %s"%(self.hrn, self.leaf, self.authority) + + def get_leaf(self): self._normalize() return self.leaf