argfinder.py 文件源码

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

项目:azure-cli-shell 作者: Azure 项目源码 文件源码
def get_parsed_args(self, comp_words):
        """ gets the parsed args from a patched parser """
        active_parsers = self._patch_argument_parser()

        parsed_args = argparse.Namespace()

        self.completing = True
        if USING_PYTHON2:
            # Python 2 argparse only properly works with byte strings.
            comp_words = [ensure_bytes(word) for word in comp_words]

        try:
            stderr = sys.stderr
            sys.stderr = io.open(os.devnull, "w")

            active_parsers[0].parse_known_args(comp_words, namespace=parsed_args)

            sys.stderr.close()
            sys.stderr = stderr
        except BaseException:
            pass

        self.completing = False
        return parsed_args
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号