def import_module(name, required=True):
    """
        Import module by name

        :param name:
            Module name
        :param required:
            If set to `True` and module was not found - will throw exception.
            If set to `False` and module was not found - will return None.
            Default is `True`.
    """
    try:
        __import__(name, globals(), locals(), [])
    except __HOLE__:
        if not required and module_not_found():
            return None
        raise
    return sys.modules[name]
dataset/ETHPy150Open flask-admin/flask-admin/flask_admin/tools.py/import_module