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]
49 raise Exception("$(glob): No match on '%s'" % v)
53 default_subs = {"file ": sub_file,
55 "basename ": sub_basename,
58 def do_substitution(p, c, subs=default_subs):
63 v = do_substitution(p, c[m[0]+2 : m[1]])
67 r = subs[sub](v[len(sub):])
73 c = c[:m[0]] + r + c[m[1]+1:]