12 if err.errno == os.errno.ENOENT:
13 head, tail = os.path.split(name)
16 elif err.errno == os.errno.EEXIST:
21 def link_or_copy(src, dest):
25 shutil.copyfile(src, dest)
27 def remove_tree_contents(dir):
28 for f in os.listdir(dir):
29 name = os.path.join(dir, f)
33 if err.errno == os.errno.EISDIR:
34 shutil.rmtree(os.path.join(dir, f))
38 def load_module(modname):
39 """Return the module `modname` (full name) if loaded, or try to import it.
40 Returns the module or raises `ImportError`."""
41 if not sys.modules.has_key(modname):
43 return sys.modules[modname]