common.py 文件源码

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

项目:ormeasy 作者: spoqa 项目源码 文件源码
def import_all_modules(
    module_name: str, path: typing.Optional[typing.Sequence[str]]=None,
) -> typing.AbstractSet[str]:
    """Import all modules. Maybe it is useful when populate revision script
    in alembic with ``--autogenerate`` option. Since alembic can only detect a
    change/creation of an object that imported in runtime, importing all
    modules helps entity to track in migration script properly.

    .. code-block:

       >>> from ormeasy.common import import_all_modules
       >>> import_all_modules('ormeasy')

    :param str module_name: The module name want to import.
    :param list[str] or None path: The path to find the root module.

    """
    modules = get_all_modules(module_name, path)
    for module_name in modules:
        importlib.import_module(module_name)
    return modules
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号