当前位置: 首页>>代码示例>>Python>>正文


Python argcomplete.CompletionFinder方法代码示例

本文整理汇总了Python中argcomplete.CompletionFinder方法的典型用法代码示例。如果您正苦于以下问题:Python argcomplete.CompletionFinder方法的具体用法?Python argcomplete.CompletionFinder怎么用?Python argcomplete.CompletionFinder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在argcomplete的用法示例。


在下文中一共展示了argcomplete.CompletionFinder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _make_argparser

# 需要导入模块: import argcomplete [as 别名]
# 或者: from argcomplete import CompletionFinder [as 别名]
def _make_argparser(self):
        """Makes a new argument parser."""
        self.argparser = ShellArgumentParser(prog='')
        subparsers = self.argparser.add_subparsers()

        for name in self.get_names():
            if name.startswith('parser_'):
                parser = subparsers.add_parser(name[7:])
                parser.set_defaults(func=getattr(self, 'arg_' + name[7:]))
                getattr(self, name)(parser)

        self.argparser_completer = None

        try:
            import argcomplete
        except ImportError:
            pass
        else:
            os.environ.setdefault("_ARGCOMPLETE_COMP_WORDBREAKS", " \t\"'")
            self.argparser_completer = argcomplete.CompletionFinder(self.argparser) 
开发者ID:ralphje,项目名称:imagemounter,代码行数:22,代码来源:shell.py

示例2: enable_autocomplete

# 需要导入模块: import argcomplete [as 别名]
# 或者: from argcomplete import CompletionFinder [as 别名]
def enable_autocomplete(self, parser):
        if self.cli_ctx.data['completer_active']:
            argcomplete.autocomplete = argcomplete.CompletionFinder()
            argcomplete.autocomplete(parser, validator=lambda c, p: c.lower().startswith(p.lower()),
                                     default_completer=lambda _: ()) 
开发者ID:microsoft,项目名称:knack,代码行数:7,代码来源:completion.py

示例3: __init__

# 需要导入模块: import argcomplete [as 别名]
# 或者: from argcomplete import CompletionFinder [as 别名]
def __init__(self, cmdname, cmdtype, repeat, prefix):

        self.cmdname = cmdname
        self.cmdtype = cmdtype
        self.repeat = repeat
        self.prefix = prefix

        # Setup a parser for this command.
        self.parser = ArgumentParser(
            prog=self.cmdname,
            description=self.__doc__)
        self.setup(self.parser)

        # We need to set the .completer hints in order for
        # argcomplete to know what to do on types we known.
        for action in self.parser._actions:
            if hasattr(action.type, "argcompleter"):
                action.completer = action.type.argcompleter

        # And prepare everything for autocompletion.
        self.completer = argcomplete.CompletionFinder(
            self.parser, always_complete_options=True)

        # gdb generates its help from the docstring.
        # We temporarilly overwrite it with argparse's output.
        old_doc, self.__doc__ = self.__doc__, self.parser.format_help().strip()

        # Call gdb's init. This will cause the command to be registerd.
        super().__init__(cmdname, cmdtype, prefix=prefix)

        # Restore the docstring so that it is usefull when looking
        # up help in python or when used for any other puprpose.
        self.__doc__ = old_doc 
开发者ID:wapiflapi,项目名称:gxf,代码行数:35,代码来源:commands.py


注:本文中的argcomplete.CompletionFinder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。