X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fnamespace.py;h=cc140d5a409db88c20fa699baf960320d3265e20;hb=5a7686e2e17d6dd86c13895ea2876a31f09bc4a2;hp=61b05b9142747eda430a19dc30cc75589abf6f59;hpb=3d7237fa0b5f2b4a60cb97c7fb3b6aecfd94558a;p=sfa.git diff --git a/sfa/util/namespace.py b/sfa/util/namespace.py index 61b05b91..cc140d5a 100644 --- a/sfa/util/namespace.py +++ b/sfa/util/namespace.py @@ -57,8 +57,9 @@ def urn_to_hrn(urn): """ # if this is already a hrn dont do anything - if not urn.startswith(URN_PREFIX): + if not urn or not urn.startswith(URN_PREFIX): return urn, None + name = urn[len(URN_PREFIX):] hrn_parts = name.split("+") @@ -71,7 +72,7 @@ def urn_to_hrn(urn): # join list elements using '.' hrn = '.'.join([part.replace(':', '.') for part in hrn_parts if part]) - return hrn, type + return str(hrn), str(type) def hrn_to_urn(hrn, type=None): @@ -79,7 +80,7 @@ def hrn_to_urn(hrn, type=None): convert an hrn and type to a urn string """ # if this is already a urn dont do anything - if hrn.startswith(URN_PREFIX): + if not hrn or hrn.startswith(URN_PREFIX): return hrn authority = get_authority(hrn)