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.MoeErr, "Unknown extension: " + ext
18 def locate(e, filename=None):
19 e.log.progress("Locating source... ")
25 dir, file = os.path.split(filename)
27 dir = e.cfgs["SOL_DIR"]
29 base, ext = os.path.splitext(file)
31 if not os.path.exists(os.path.join(dir, file)):
32 raise moe.SolutionErr, "No solution of %s called %s found" % (task,file)
37 for ext in e.cfgs["EXTENSIONS"].split():
38 if os.path.exists(os.path.join(dir, base + "." + ext)):
41 raise moe.SolutionErr, "No solution of %s found" % task
43 raise moe.SolutionErr, "Multiple solutions of %s found" % task
45 file = base + "." + ext
47 orig_path = os.path.join(dir, file)
48 norm_ext = normalize_ext(e, ext)
49 e.log.verbose("Found solution %s\n" % orig_path)
51 copy = e.cfgs["TASK"] + "." + norm_ext
52 copy_path = os.path.join(e.cfgs["TEST_DIR"], copy)
54 e.log.verbose("Renaming to %s\n" % copy)
55 moe.util.link_or_copy(orig_path, copy_path)
57 e.builtins.set("SRC", copy)
58 e.builtins.set("EXT", norm_ext)
59 e.cfgs.apply_overrides("EXT_" + norm_ext)
61 e.stat["source"] = file
62 e.log.progress(file + "\n")
71 e.main_pipe.insert(100, "compile", compile)
72 e.main_pipe.insert(200, "batch-tests", tests)