7 def normalize_ext(e, ext):
8 alias = e.cfgs["ALIAS_EXT_" + ext]
9 return alias if alias != "" else ext
12 for e in e.cfgs["EXTENSIONS"].split():
15 raise moe.eval.MoeEvalErr, "Unknown extension: " + ext
17 def locate(e, filename=None):
23 dir, file = os.path.split(filename)
25 dir = e.cfgs["SOL_DIR"]
27 base, ext = os.path.splitext(file)
29 if not os.path.exists(os.path.join(dir, file)):
30 raise moe.eval.MoeEvalErr, "No solution of %s called %s found" % (task,file)
35 for ext in e.cfgs["EXTENSIONS"].split():
36 if os.path.exists(os.path.join(dir, base + "." + ext)):
39 raise moe.eval.MoeEvalErr, "No solution of %s found" % task
41 raise moe.eval.MoeEvalErr, "Multiple solutions of %s found" % task
43 file = base + "." + ext
45 orig_path = os.path.join(dir, file)
46 norm_ext = normalize_ext(e, ext)
47 e.log.verbose("Found solution %s\n" % orig_path)
49 copy = e.cfgs["TASK"] + "." + norm_ext
50 copy_path = os.path.join(e.cfgs["TEST_DIR"], copy)
52 e.log.verbose("Renaming to %s\n" % copy)
53 moe.util.link_or_copy(orig_path, copy_path)
55 e.builtins.set("SRC", copy)
56 e.builtins.set("EXT", norm_ext)
57 e.cfgs.apply_overrides("EXT_" + norm_ext)
59 e.meta["source"] = copy
68 e.main_pipe.insert(100, "compile", compile)
69 e.main_pipe.insert(200, "batch-tests", tests)