X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fxrn.py;h=6198f83c7f57465cd6b22f8ed026372f07926ec7;hb=ecc85e0b923922cf7117d29b380f5284edb88f21;hp=dfcf3e5bec9db5a3cdadd0a0b2e3a7003bf10617;hpb=8f367b9457f47ba1e3b8a56eea8ed5c9b1e52eed;p=sfa.git diff --git a/sfa/util/xrn.py b/sfa/util/xrn.py index dfcf3e5b..6198f83c 100644 --- a/sfa/util/xrn.py +++ b/sfa/util/xrn.py @@ -110,22 +110,15 @@ class Xrn: return Xrn.urn_meaningful(urn).split('+') @staticmethod - def filter_type(urns=[], type=None): + def filter_type(urns=None, type=None): + if urns is None: urns=[] urn_list = [] if not type: return urns for urn in urns: xrn = Xrn(xrn=urn) - if not xrn.type: - # If an xrn doesn't have a type its probably a hrn. - # We have to make some assumptions on the hrn's type - # based on the contents of the hrn. - if type == 'sliver' and '-' in xrn.leaf: - urn_list.append(urn) - elif type != 'sliver' and not '-' in xrn.leaf: - urn_list.append(urn) - elif (xrn.type == type): + if (xrn.type == type): # Xrn is probably a urn so we can just compare types urn_list.append(urn) return urn_list @@ -169,7 +162,7 @@ class Xrn: def get_hrn_type(self): return (self.hrn, self.type) def _normalize(self): - if self.hrn is None: raise SfaAPIError, "Xrn._normalize" + 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 @@ -218,7 +211,7 @@ class Xrn: # if not self.urn or not self.urn.startswith(Xrn.URN_PREFIX): if not Xrn.is_urn(self.urn): - raise SfaAPIError, "Xrn.urn_to_hrn" + raise SfaAPIError("Xrn.urn_to_hrn") parts = Xrn.urn_split(self.urn) type=parts.pop(2) @@ -256,7 +249,7 @@ class Xrn: # if not self.hrn or self.hrn.startswith(Xrn.URN_PREFIX): if Xrn.is_urn(self.hrn): - raise SfaAPIError, "Xrn.hrn_to_urn, hrn=%s"%self.hrn + raise SfaAPIError("Xrn.hrn_to_urn, hrn=%s"%self.hrn) if self.type and self.type.startswith('authority'): self.authority = Xrn.hrn_auth_list(self.hrn)