dochelpers.py 文件源码

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

项目:qubes-core-admin-client 作者: QubesOS 项目源码 文件源码
def __init__(self, app, command, document):
        docutils.nodes.SparseNodeVisitor.__init__(self, document)
        try:
            parser = qubesadmin.tools.get_parser_for_command(command)
        except ImportError:
            app.warn('cannot import module for command')
            self.parser = None
            return
        except AttributeError:
            raise sphinx.errors.SphinxError('cannot find parser in module')

        self.command = command
        self.parser = parser
        self.options = set()
        self.sub_commands = {}
        self.app = app

        # pylint: disable=protected-access
        for action in parser._actions:
            if action.help == argparse.SUPPRESS:
                continue

            if issubclass(action.__class__,
                          qubesadmin.tools.AliasedSubParsersAction):
                for cmd, cmd_parser in action._name_parser_map.items():
                    self.sub_commands[cmd] = set()
                    for sub_action in cmd_parser._actions:
                        if sub_action.help != argparse.SUPPRESS:
                            self.sub_commands[cmd].update(
                                sub_action.option_strings)
            else:
                self.options.update(action.option_strings)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号