X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=blobdiff_plain;f=sfa%2Futil%2Fxrn.py;h=a21b10c02d1b29f72f2d2fbfe0ea9296e2af6562;hp=f48a37732a713796ef316d8997ea7199d77aa741;hb=3d51e29695f79b143974f5cf7b2e104d89626ba4;hpb=04255538dbacfa52a45e8439b9c9ea590a82dc47 diff --git a/sfa/util/xrn.py b/sfa/util/xrn.py index f48a3773..a21b10c0 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") @@ -143,13 +146,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