From: Barış Metin Date: Mon, 18 Oct 2010 14:46:49 +0000 (+0200) Subject: simpler and hopefully less error-prone way to init Xrn X-Git-Tag: sfa-1.0-5~11^2~3 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=27bb1bc91017a36976dcdb0c26894fcda0696345;p=sfa.git simpler and hopefully less error-prone way to init Xrn --- diff --git a/sfa/util/xrn.py b/sfa/util/xrn.py index 86a1f863..c00dcef4 100644 --- a/sfa/util/xrn.py +++ b/sfa/util/xrn.py @@ -56,23 +56,22 @@ class Xrn: # provide either urn, or (hrn + type) def __init__ (self, xrn=None, urn=None, hrn=None, type=None): - if xrn: - if xrn.startswith(Xrn.URN_PREFIX): - self.urn=xrn - self.urn_to_hrn() + if not xrn: + if urn: + xrn = urn + elif hrn: + xrn = hrn else: - self.hrn=xrn - self.type=type - self.hrn_to_urn() - elif urn: - self.urn=urn + raise SfaAPIError,"Xrn.__init__" + + if xrn.startswith(Xrn.URN_PREFIX): + self.urn=xrn self.urn_to_hrn() - elif hrn and type: - self.hrn=hrn + else: + self.hrn=xrn self.type=type self.hrn_to_urn() - else: - raise SfaAPIError,"Xrn.__init__" + if not type: sfa_logger().debug("type-less Xrn's are not safe")