MCPcopy Index your code
hub / github.com/RustPython/RustPython / _more_lines

Function _more_lines

Lib/_pyrepl/simple_interact.py:86–102  ·  view source on GitHub ↗
(console: code.InteractiveConsole, unicodetext: str)

Source from the content-addressed store, hash-verified

84
85
86def _more_lines(console: code.InteractiveConsole, unicodetext: str) -> bool:
87 # ooh, look at the hack:
88 src = _strip_final_indent(unicodetext)
89 try:
90 code = console.compile(src, "<stdin>", "single")
91 except (OverflowError, SyntaxError, ValueError):
92 lines = src.splitlines(keepends=True)
93 if len(lines) == 1:
94 return False
95
96 last_line = lines[-1]
97 was_indented = last_line.startswith((" ", "\t"))
98 not_empty = last_line.strip() != ""
99 incomplete = not last_line.endswith("\n")
100 return (was_indented or not_empty) and incomplete
101 else:
102 return code is None
103
104
105def run_multiline_interactive_console(

Callers

nothing calls this directly

Calls 7

_strip_final_indentFunction · 0.85
lenFunction · 0.85
compileMethod · 0.45
splitlinesMethod · 0.45
startswithMethod · 0.45
stripMethod · 0.45
endswithMethod · 0.45

Tested by

no test coverage detected