11 if err.errno == os.errno.ENOENT:
12 head, tail = os.path.split(name)
15 elif err.errno == os.errno.EEXIST:
20 def link_or_copy(src, dest):
24 shutil.copyfile(src, dest)
26 def remove_tree_contents(dir):
27 for f in os.listdir(dir):
28 name = os.path.join(dir, f)
32 if err.errno == os.errno.EISDIR:
33 shutil.rmtree(os.path.join(dir, f))
37 def load_module(modname):
38 """Return the module `modname` (full name) if loaded, or try to import it.
39 Returns the module or raises `ImportError`."""
40 if not sys.modules.has_key(modname):
41 moe.log.debug("Loading module %s" % (path, name))
43 return sys.modules[modname]