MCPcopy Index your code
hub / github.com/prompt-toolkit/ptpython / _lex_python_result

Function _lex_python_result

src/ptpython/printer.py:430–439  ·  view source on GitHub ↗

Return token list for Python string.

(result: str)

Source from the content-addressed store, hash-verified

428
429
430def _lex_python_result(result: str) -> Generator[tuple[str, str], None, None]:
431 "Return token list for Python string."
432 lexer = PythonLexer()
433 # Use `get_tokens_unprocessed`, so that we get exactly the same string,
434 # without line endings appended. `print_formatted_text` already appends a
435 # line ending, and otherwise we'll have two line endings.
436 tokens = lexer.get_tokens_unprocessed(result)
437
438 for index, tokentype, text in tokens:
439 yield ("class:" + pygments_token_to_classname(tokentype), text)

Callers 1

_format_result_outputMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected