parser.py 文件源码

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

项目:helcli 作者: sunshinekitty 项目源码 文件源码
def gen_parser(caller, commands, parser, subparsers):
    """
    Run setup() for all submodules of sub_commands
    :param caller: Module calling this module
    :type caller: string
    :param commands: Sub-module relative to caller with commands
    :type commands: string
    :param parser: Argparse object
    :type parser: argparse.ArgumentParser
    :param subparsers: Subparsers object
    :type subparsers: argparse._SubParsersAction
    """
    package = importlib.import_module('{}.{}'.format(caller, commands))
    for importer, modname, ispkg in \
            pkgutil.iter_modules(package.__path__,
                                 prefix='{}.{}.'.format(caller, commands)):
        if not ispkg:
            found_module = importlib.import_module('{}'.format(modname))
            found_module.setup(parser, subparsers)

# vim:et:fdm=marker:sts=4:sw=4:ts=4
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号