8 def normalize_ext(e, ext):
9 alias = e.cfgs["ALIAS_EXT_" + ext]
10 return alias if alias != "" else ext
13 for e in e.cfgs["EXTENSIONS"].split():
16 raise moe.eval.MoeEvalErr, "Unknown extension: " + ext
18 def locate(e, filename=None):
24 dir, file = os.path.split(filename)
26 dir = e.cfgs["SOL_DIR"]
28 base, ext = os.path.splitext(file)
30 if not os.path.exists(os.path.join(dir, file)):
31 raise moe.eval.MoeEvalErr, "No solution of %s called %s found" % (task,file)
36 for ext in e.cfgs["EXTENSIONS"].split():
37 if os.path.exists(os.path.join(dir, base + "." + ext)):
40 raise moe.eval.MoeEvalErr, "No solution of %s found" % task
42 raise moe.eval.MoeEvalErr, "Multiple solutions of %s found" % task
44 file = base + "." + ext
46 orig_path = os.path.join(dir, file)
47 norm_ext = normalize_ext(e, ext)
48 moe.log.verbose("Found solution %s\n" % orig_path)
50 copy = e.cfgs["TASK"] + "." + norm_ext
51 copy_path = os.path.join(e.cfgs["TEST_DIR"], copy)
53 moe.log.verbose("Renaming to %s\n" % copy)
54 moe.util.link_or_copy(orig_path, copy_path)
56 e.builtins.set("SRC", copy)
57 e.builtins.set("EXT", norm_ext)
58 e.cfgs.apply_overrides("EXT_" + norm_ext)
60 e.meta["source"] = copy
69 e.main_pipe.insert(100, "compile", compile)
70 e.main_pipe.insert(200, "batch-tests", tests)