15 elif state == DEFAULT:
31 raise Exception("Substitution error, mismatched parentheses {}".format(c))
35 return os.path.join(os.environ['TASK_KEEPMOUNT'], v)
38 d = os.path.dirname(v)
41 return os.path.join(os.environ['TASK_KEEPMOUNT'], d)
44 return os.path.splitext(os.path.basename(v))[0]
47 return glob.glob(v)[0]
49 default_subs = {"file ": sub_file,
51 "basename ": sub_basename,
54 def do_substitution(p, c, subs=default_subs):
59 v = do_substitution(p, c[m[0]+2 : m[1]])
63 r = subs[sub](v[len(sub):])
69 c = c[:m[0]] + r + c[m[1]+1:]