def import_class(module_name):
    """
    Import a module with a reasonable traceback and return that module as the
    variable.

    eg. dumps = import_class('simplejson.dumps')
    if dumps is None:
        dumps = import_class('json.dumps')

    Reference: http://lucumr.pocoo.org/2011/9/21/python-import-blackbox/
    Written by: Armin Ronacher
    """

    module, klass = module_name.rsplit('.', 1)
    try:
        __import__(module)
    except __HOLE__:
        exc_type, exc_value, tb_root = sys.exc_info()
        logger.warning(exc_type)
        logger.warning(exc_value)
        tb = tb_root
        while tb is not None:
            if tb.tb_frame.f_globals.get('__name__') == module:
                raise exc_type, exc_value, tb_root
            tb = tb.tb_next
        return None
    return getattr(sys.modules[module], klass)
dataset/ETHPy150Open winhamwr/neckbeard/neckbeard/cloud_provisioners/base.py/import_class