__init__.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:hangoutsbot 作者: das7pad 项目源码 文件源码
def load_module(module_path):
    """(re) load an external module

    Args:
        module_path: string, the path to the module relative to the main script

    Returns:
        boolean, True if no Exception was raised on (re)load, otherwise False
    """
    message = "search for plugin in sys.modules"
    try:
        if module_path in sys.modules:
            message = "reload"
            importlib.reload(sys.modules[module_path])

        else:
            message = "import"
            importlib.import_module(module_path)

        return True
    except:             # capture all Exceptions   # pylint: disable=bare-except
        logger.exception("load_module %s: %s", module_path, message)
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号