X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=t%2Fmoe%2Futil.py;h=d287ff864c1230709b3172d658af4e1f3f157297;hb=5ad8b4f69ab4fdf4d75f5a56fc72ef2988f1da1f;hp=c7bbb5f4eea1dfdf8b68dde99cae8c0a01c02eaa;hpb=224eb93fad8979a07aeddc800ac73a84c775b27e;p=eval.git diff --git a/t/moe/util.py b/t/moe/util.py index c7bbb5f..d287ff8 100644 --- a/t/moe/util.py +++ b/t/moe/util.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import os +import sys import os.path import shutil @@ -33,3 +34,10 @@ def remove_tree_contents(dir): shutil.rmtree(os.path.join(dir, f)) else: raise err + +def load_module(modname): + """Return the module `modname` (full name) if loaded, or try to import it. + Returns the module or raises `ImportError`.""" + if not sys.modules.has_key(modname): + __import__(modname) + return sys.modules[modname]