Changeset ab847bc for fedd/federation/util.py
- Timestamp:
- Apr 28, 2010 4:09:53 AM (14 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 12658df
- Parents:
- 05fceef
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/util.py
r05fceef rab847bc 213 213 raise failed_excpetion 214 214 215 # Functions to manipulate composite testbed names 216 def testbed_base(tb): 217 """ 218 Simple code to get the base testebd name. 219 """ 220 i = tb.find('/') 221 if i == -1: return tb 222 else: return tb[0:i] 223 224 def testbed_suffix(tb): 225 """ 226 Simple code to get a testbed suffix, if nay. No suffix returns None. 227 """ 228 i = tb.find('/') 229 if i != -1: return tb[i+1:] 230 else: return None 231 232 def split_testbed(tb): 233 """ 234 Return a testbed and a suffix as a tuple. No suffix returns None for that 235 field 236 """ 237 238 i = tb.find('/') 239 if i != -1: return (tb[0:i], tb[i+1:]) 240 else: return (tb, None) 241 242 def join_testbed(base, suffix=None): 243 """ 244 Build a testbed with suffix. If base is itself a tuple, combine them, 245 otherwise combine the two. 246 """ 247 if isinstance(base, tuple): 248 if len(base) == 2: 249 return '/'.join(base) 250 else: 251 raise RuntimeError("Too many tuple elements for join_testbed") 252 else: 253 if suffix: 254 return '/'.join((base, suffix)) 255 else: 256 return base
Note: See TracChangeset
for help on using the changeset viewer.