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


Python auto_suggest.AutoSuggestFromHistory方法代码示例

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


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

示例1: main

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def main():
    settings = Settings()
    bindings = get_bindings(settings)
    executor = Executor(settings)
    toolbar = Toolbar(settings)
    completer = KafkaCompleter(settings) if settings.enable_auto_complete else None
    suggester = AutoSuggestFromHistory() if settings.enable_auto_suggest else None
    history = ThreadedHistory(FileHistory(get_user_history_path())) if settings.enable_history else InMemoryHistory()
    session = PromptSession(completer=completer, style=style, bottom_toolbar=toolbar.handler,
                            key_bindings=bindings, history=history, include_default_pygments_style=False)
    while True:
        try:
            command = session.prompt([("class:operator", "> ")], auto_suggest=suggester)
        except KeyboardInterrupt:
            continue
        except EOFError:
            break
        else:
            executor.execute(command)

    settings.save_settings() 
开发者ID:devshawn,项目名称:kafka-shell,代码行数:23,代码来源:main.py

示例2: prompt

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def prompt(commands, module=None):
    """Launch the prompt with the given commands
    
    Args:
        commands ([str]): List of commands to autocomplete
        module (str, optional): Name of the module. Defaults to None.
    
    Returns:
        prompt session: Session of the promt
    """
    default_prompt = "homePwn"
    color_default_prompt = ColorSelected().theme.primary
    warn = ColorSelected().theme.warn
    confirm = ColorSelected().theme.confirm
    html = HTML(f"<bold><{color_default_prompt}>{default_prompt} >></{color_default_prompt}></bold>")
    if module:
        html = HTML(f"<bold><{color_default_prompt}>{default_prompt}</{color_default_prompt}> (<{warn}>{module}</{warn}>) <{confirm}>>></{confirm}></bold> ")
    data = session.prompt(
        html,
        completer= CustomCompleter(commands),
        complete_style=CompleteStyle.READLINE_LIKE,
        auto_suggest=AutoSuggestFromHistory(),
        enable_history_search=True)
    return  data 
开发者ID:ElevenPaths,项目名称:HomePWN,代码行数:26,代码来源:prompt.py

示例3: __init__

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def __init__(self, parser, engine, options=None):
        self.parser = parser
        self.engine = engine
        self.options = options if options is not None else {}
        util.ensure_data_dir_exists()
        application = create_prompt_application(
            message='> ',
            lexer=PygmentsLexer(SqlLexer),
            history=FileHistory(os.path.expanduser('~/.aq/history')),
            completer=AqCompleter(schemas=engine.available_schemas, tables=engine.available_tables),
            auto_suggest=AutoSuggestFromHistory(),
            validator=QueryValidator(parser),
            on_abort=AbortAction.RETRY,
        )
        loop = create_eventloop()
        self.cli = CommandLineInterface(application=application, eventloop=loop)
        self.patch_context = self.cli.patch_stdout_context() 
开发者ID:lebinh,项目名称:aq,代码行数:19,代码来源:prompt.py

示例4: __init__

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def __init__(self, db_path):
        self.db_path = db_path

        self.completer = WMCompleter(self)
        self.signatures = Signatures()
        self.prompt_session = PromptSession(
            HTML("WMDB ≫ "),
            #bottom_toolbar=functools.partial(bottom_toolbar, ts=self.teamservers),
            completer=self.completer,
            complete_in_thread=True,
            complete_while_typing=True,
            auto_suggest=AutoSuggestFromHistory(),
            #rprompt=get_rprompt(False),
            #style=example_style,
            search_ignore_case=True
        ) 
开发者ID:byt3bl33d3r,项目名称:WitnessMe,代码行数:18,代码来源:wmdb.py

示例5: main

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def main():
    """ 
         Start the Slack Client 
    """
    os.system("clear; figlet 'Slack Gitsin' | lolcat")
    history = FileHistory(os.path.expanduser("~/.slackHistory"))
    while True:
        text = prompt("slack> ", history=history,
                      auto_suggest=AutoSuggestFromHistory(),
                      on_abort=AbortAction.RETRY,
                      style=DocumentStyle,
                      completer=Completer(fuzzy_match=False,
                                          text_utils=TextUtils()),
                      complete_while_typing=Always(),
                      get_bottom_toolbar_tokens=get_bottom_toolbar_tokens,
                      key_bindings_registry=manager.registry,
                      accept_action=AcceptAction.RETURN_DOCUMENT
        )
        slack = Slack(text)
        slack.run_command() 
开发者ID:yasintoy,项目名称:Slack-Gitsin,代码行数:22,代码来源:main.py

示例6: _do_shell

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def _do_shell(_args):
    commands = ['compile', 'convert', 'help', 'exit']
    completer = WordCompleter(commands, WORD=True)
    user_home = os.path.expanduser('~')
    history = FileHistory(os.path.join(user_home, '.asn1tools-history.txt'))
    session = PromptSession(completer=completer,
                            complete_while_typing=True,
                            auto_suggest=AutoSuggestFromHistory(),
                            enable_history_search=True,
                            history=history)
    input_spec = None
    output_spec = None
    output_codec = None

    print("\nWelcome to the asn1tools shell!\n")

    while True:
        try:
            line = session.prompt(u'$ ')
        except EOFError:
            return

        line = line.strip()

        if line:
            if line.startswith('compile'):
                input_spec, output_spec, output_codec = _handle_command_compile(line)
            elif line.startswith('convert'):
                _handle_command_convert(line,
                                        input_spec,
                                        output_spec,
                                        output_codec)
            elif line == 'help':
                _handle_command_help()
            elif line == 'exit':
                return
            else:
                print('{}: command not found'.format(line)) 
开发者ID:eerimoq,项目名称:asn1tools,代码行数:40,代码来源:__init__.py

示例7: custom_prompt

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def custom_prompt(currentSong): 
    
    session = PromptSession(
        message=get_prompt,
        history=history(),
        auto_suggest=AutoSuggestFromHistory(),
        enable_history_search=True,
        bottom_toolbar=get_bottom_toolbar(currentSong),
        completer=completer(),
        complete_while_typing=True,
        complete_in_thread=True,
        style=style
    )

    return session.prompt() 
开发者ID:bjarneo,项目名称:Pytify,代码行数:17,代码来源:prompt.py

示例8: shell

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def shell(self, items, pargs):
        self.pargs = pargs
        self.items = items
        stdout.write(
            '\n')  # When the fetching messege ends need to add \n after \r.
        self.prompt_show_items()
        history = InMemoryHistory()

        session = PromptSession() if PROMPT_TOOLKIT_V2 else None
        while True:
            kwargs = dict(
                history=history,
                auto_suggest=AutoSuggestFromHistory(),
                completer=WGCompleter(list(self.items.keys())),
                style=we_get_prompt_style
            )
            try:
                p = prompt(u'we-get > ', **kwargs)
            except TypeError as e:
                log.debug('{}:{}'.format(type(e), e))
                kwargs.pop('history')
                if PROMPT_TOOLKIT_V2:
                    p = session.prompt(u'we-get > ', **kwargs)
                else:
                    p = prompt(u'we-get > ', **kwargs)

            if self.prompt_no_command(p):
                continue
            elif self.prompt_is_single_command(p):
                command = p
                args = None
            else:
                _ = p.split()
                command = _[0]
                _.pop(0)
                args = ' '.join(_)
            if not self.prompt_verify_command(command, args):
                continue
            elif not self.prompt_parse_command(command, args):
                break 
开发者ID:rachmadaniHaryono,项目名称:we-get,代码行数:42,代码来源:shell.py

示例9: run

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def run(self):
        """Runs the interface and waits for user input commands."""
        completer = WordCompleter(['show', 'name', 'field', 'fields',
                                   'dump', 'recalculate', 'clear', 'back'])
        history = FileHistory(self._polym_path + '/.linterface_history')
        session = PromptSession(history=history)
        while True:
            try:
                command = session.prompt(HTML("<bold>PH:cap/t%d/<red>%s</red> > </bold>" %
                                              (self._tindex, self._l.name)),
                                         completer=completer,
                                         complete_style=CompleteStyle.READLINE_LIKE,
                                         auto_suggest=AutoSuggestFromHistory(),
                                         enable_history_search=True)
            except KeyboardInterrupt:
                self.exit_program()
                continue
            # Argument parsing
            command = command.split(" ")
            if command[0] in self.EXIT:
                self.exit_program()
            elif command[0] in self.RET:
                break
            elif command[0] in ["s", "show"]:
                self._show(command)
            elif command[0] == "name":
                self._name(command)
            elif command[0] in ["field", "f"]:
                self._field(command)
            elif command[0] in ["fields", "fs"]:
                self._fields(command)
            elif command[0] in ["dump", "d"]:
                self._dump(command)
            elif command[0] in ["recalculate", "r"]:
                self._recalculate(command)
            elif command[0] == "clear":
                Interface._clear()
            elif command[0] == "":
                continue
            else:
                Interface._wrong_command() 
开发者ID:shramos,项目名称:polymorph,代码行数:43,代码来源:layerinterface.py

示例10: run

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def run(self):
        """Runs the interface and waits for user input commands."""
        completer = WordCompleter(['show', 'dissect', 'template', 'wireshark',
                                   'clear', 'back'])
        history = FileHistory(self._polym_path + '/.tlinterface_history')
        session = PromptSession(history=history)
        while True:
            try:
                command = session.prompt(HTML("<bold>PH:<red>cap</red> > </bold>"),
                                         completer=completer,
                                         complete_style=CompleteStyle.READLINE_LIKE,
                                         auto_suggest=AutoSuggestFromHistory(),
                                         enable_history_search=True)
            except KeyboardInterrupt:
                self.exit_program()
                continue
            command = command.split(" ")
            if command[0] in self.EXIT:
                self.exit_program()
            elif command[0] in self.RET:
                break
            elif command[0] in ["show", "s"]:
                self._show(command)
            elif command[0] == "dissect":
                self._dissect(command)
            elif command[0] in ["template", "t"]:
                self._template(command)
            elif command[0] in ["wireshark", "w"]:
                self._wireshark(command)
            elif command[0] == "clear":
                Interface._clear()
            elif command[0] == "":
                continue
            else:
                Interface._wrong_command() 
开发者ID:shramos,项目名称:polymorph,代码行数:37,代码来源:tlistinterface.py

示例11: run

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def run(self):
        """Runs the interface and waits for user input commands."""
        completer = WordCompleter(['capture', 'spoof', 'clear', 'import'])
        history = FileHistory(self._polym_path + '/.minterface_history')
        session = PromptSession(history=history)
        while True:
            try:
                command = session.prompt(HTML("<bold><red>PH</red> > </bold>"),
                                         completer=completer,
                                         complete_style=CompleteStyle.READLINE_LIKE,
                                         auto_suggest=AutoSuggestFromHistory(),
                                         enable_history_search=True)
            except KeyboardInterrupt:
                self.exit_program()
                continue
            command = command.split(" ")
            if command[0] in self.EXIT:
                self.exit_program()
            elif command[0] in ["capture", "c"]:
                self._capture(command)
            elif command[0] in ["spoof", "s"]:
                self._spoof(command)
            elif command[0] in ["import", "i"]:
                self._import(command)
            elif command[0] == "clear":
                Interface._clear()
            elif command[0] == "":
                continue
            else:
                Interface._wrong_command() 
开发者ID:shramos,项目名称:polymorph,代码行数:32,代码来源:maininterface.py

示例12: create_application

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def create_application(self, full_layout=True):
        """ makes the application object and the buffers """
        if full_layout:
            layout = create_layout(self.lexer, ExampleLexer, ToolbarLexer)
        else:
            layout = create_tutorial_layout(self.lexer)

        buffers = {
            DEFAULT_BUFFER: Buffer(is_multiline=True),
            'description': Buffer(is_multiline=True, read_only=True),
            'parameter' : Buffer(is_multiline=True, read_only=True),
            'examples' : Buffer(is_multiline=True, read_only=True),
            'bottom_toolbar' : Buffer(is_multiline=True),
            'example_line' : Buffer(is_multiline=True),
            'default_values' : Buffer(),
            'symbols' : Buffer()
        }

        writing_buffer = Buffer(
            history=self.history,
            auto_suggest=AutoSuggestFromHistory(),
            enable_history_search=True,
            completer=self.completer,
            complete_while_typing=Always()
        )

        return Application(
            mouse_support=False,
            style=self.styles,
            buffer=writing_buffer,
            on_input_timeout=self.on_input_timeout,
            key_bindings_registry=registry,
            layout=layout,
            buffers=buffers,
        ) 
开发者ID:Azure,项目名称:azure-cli-shell,代码行数:37,代码来源:app.py

示例13: main

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def main():
    # Create some history first. (Easy for testing.)
    history = InMemoryHistory()
    history.append_string("import os")
    history.append_string('print("hello")')
    history.append_string('print("world")')
    history.append_string("import path")

    # Print help.
    print("This CLI has fish-style auto-suggestion enable.")
    print('Type for instance "pri", then you\'ll see a suggestion.')
    print("Press the right arrow to insert the suggestion.")
    print("Press Control-C to retry. Control-D to exit.")
    print()

    session = PromptSession(
        history=history,
        auto_suggest=AutoSuggestFromHistory(),
        enable_history_search=True,
    )

    while True:
        try:
            text = session.prompt("Say something: ")
        except KeyboardInterrupt:
            pass  # Ctrl-C pressed. Try again.
        else:
            break

    print("You said: %s" % text) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:32,代码来源:auto-suggestion.py

示例14: create_buffer

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def create_buffer(self, completer, history):
        return Buffer(
            history=history,
            auto_suggest=AutoSuggestFromHistory(),
            enable_history_search=True,
            completer=completer,
            complete_while_typing=Always(),
            accept_action=AcceptAction.RETURN_DOCUMENT) 
开发者ID:awslabs,项目名称:aws-shell,代码行数:10,代码来源:app.py

示例15: __init__

# 需要导入模块: from prompt_toolkit import auto_suggest [as 别名]
# 或者: from prompt_toolkit.auto_suggest import AutoSuggestFromHistory [as 别名]
def __init__(self) -> None:
        self.commands = self.get_commands()
        self.cmd_handler = CommandHandler(self.commands)
        self.completer = CommandCompleter(self.commands)
        self.style = self.get_style()
        self._break = False
        self.prompt_session = PromptSession(completer=self.completer, style=self.style,
                                            bottom_toolbar=self.bottom_toolbar,
                                            auto_suggest=AutoSuggestFromHistory())
        super(CommandPrompt, self).__init__()

    # --------------------------------------------------------------- # 
开发者ID:nccgroup,项目名称:fuzzowski,代码行数:14,代码来源:prompt.py


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