X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=blobdiff_plain;f=sfa%2Futil%2Fxrn.py;h=71731d9e503f3bae295fefcdb9a641e8fb71bf73;hp=a503e713e3bb642c442de65dedb3ff713e94f36d;hb=db03eb2324ae3cc66232f7bedccf3f3f204349c7;hpb=bffe7b3b8e8a8c0b50d2c7d7a3b34323f275a79e diff --git a/sfa/util/xrn.py b/sfa/util/xrn.py index a503e713..71731d9e 100644 --- a/sfa/util/xrn.py +++ b/sfa/util/xrn.py @@ -4,10 +4,10 @@ from sfa.util.faults import * from sfa.util.sfalogging import sfa_logger # for convenience and smoother translation - we should get rid of these functions eventually -def get_leaf(hrn): return Xrn(xrn=hrn).get_leaf() -def get_authority(hrn): return Xrn(xrn=hrn).get_authority_hrn() -def urn_to_hrn(urn): xrn=Xrn(xrn=urn); return (xrn.hrn, xrn.type) -def hrn_to_urn(hrn,type): return Xrn(hrn=hrn, type=type).urn +def get_leaf(hrn): return Xrn(hrn).get_leaf() +def get_authority(hrn): return Xrn(hrn).get_authority_hrn() +def urn_to_hrn(urn): xrn=Xrn(urn); return (xrn.hrn, xrn.type) +def hrn_to_urn(hrn,type): return Xrn(hrn, type=type).urn class Xrn: @@ -60,26 +60,18 @@ class Xrn: # self.type # self.path # provide either urn, or (hrn + type) - def __init__ (self, xrn=None, urn=None, hrn=None, type=None): + def __init__ (self, xrn, type=None): # user has specified xrn : guess if urn or hrn if xrn is not None: if xrn.startswith(Xrn.URN_PREFIX): + self.hrn=None self.urn=xrn self.urn_to_hrn() else: + self.urn=None self.hrn=xrn self.type=type self.hrn_to_urn() - # user has specified urn, let's use it - elif urn is not None: - self.urn=urn - self.urn_to_hrn() - # user has specified hrn and type - elif hrn is not None and type is not None: - self.hrn=hrn - self.type=type - self.hrn_to_urn() - # what should we do ? else: raise SfaAPIError,"Xrn.__init__" # happens all the time ..