whitespace
[sfa.git] / geni / util / misc.py
1 from excep import *
2
3 def get_leaf(hrn):
4     parts = hrn.split(".")
5     return ".".join(parts[-1:])
6
7 def get_authority(hrn):
8     
9     parts = hrn.split(".")
10     return ".".join(parts[:-1])
11
12 def get_auth_type(type):
13     if (type=="slice") or (type=="user") or (type=="sa"):
14         return "sa"
15     elif (type=="component") or (type=="ma"):
16         return "ma"
17     else:
18         raise UnknownGeniType(type)
19
20 def hrn_to_pl_slicename(hrn):
21     parts = hrn.split(".")
22     return parts[-2] + "_" + parts[-1]
23
24 # assuming hrn is the hrn of an authority, return the plc authority name
25 def hrn_to_pl_authname(hrn):
26     parts = hrn.split(".")
27     return parts[-1]
28
29 # assuming hrn is the hrn of an authority, return the plc login_base
30 def hrn_to_pl_login_base(hrn):
31     return hrn_to_pl_authname(hrn)
32