def _importAndCheckStack(importName):
try:<EOL><INDENT>return __import__(importName)<EOL><DEDENT>except ImportError:<EOL><INDENT>excType, excValue, excTraceback = sys.exc_info()<EOL>while excTraceback:<EOL><INDENT>execName = excTraceback.tb_frame.f_globals["<STR_LIT>"]<EOL>if execName is None or execName == importName:<EOL><INDENT>reraise(excValue, excTraceback)<EOL><DEDENT>excTraceback = excTraceback.tb_next<EOL><DEDENT>raise _NoModuleFound()<EOL><DEDENT>
Import the given name as a module, then walk the stack to determine whether
the failure was the module not existing, or some code in the module (for
example a dependent import) failing.  This can be helpful to determine
whether any actual application code was run.  For example, to distiguish
administrative error (entering the wrong module name), from programmer
error (writing buggy code in a module that fails to import).

@param importName: The name of the module to import.
@type importName: C{str}
@raise Exception: if something bad happens.  This can be any type of
    exception, since nobody knows what loading some arbitrary code might
    do.
@raise _NoModuleFound: if no module was found.