providers.py 文件源码

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

项目:pandachaika 作者: pandabuilder 项目源码 文件源码
def _get_provider_submodule_method(module_name: str, submodule_name: str, method_name: str) -> Optional[Callable]:
    sub_module = "{}.{}".format(module_name, submodule_name)
    try:
        importlib.import_module(module_name, package='__path__')
    except ImportError:
        return None
    if importlib.util.find_spec(sub_module):
        site = importlib.import_module(sub_module, package=module_name)
        if hasattr(site, method_name):
            obj = getattr(site, method_name)
            if inspect.isfunction(obj):
                return obj
    return None


# We should only create one ProviderContext over the program lifetime,
# to avoid having to search the file system every time it's created.
# This is why this should be outside Settings
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号