MCPcopy Index your code
hub / github.com/bpython/bpython / format

Method format

bpython/curtsiesfrontend/interpreter.py:97–120  ·  view source on GitHub ↗
(self, tbtext: str, lexer: Any)

Source from the content-addressed store, hash-verified

95 # TODO for tracebacks get_lexer_by_name("pytb", stripall=True)
96
97 def format(self, tbtext: str, lexer: Any) -> None:
98 # FIXME: lexer should be "Lexer"
99 traceback_informative_formatter = BPythonFormatter(default_colors)
100 traceback_code_formatter = BPythonFormatter({Token: "d"})
101
102 no_format_mode = False
103 cur_line = []
104 for token, text in lexer.get_tokens(tbtext):
105 if text.endswith("\n"):
106 cur_line.append((token, text))
107 if no_format_mode:
108 traceback_code_formatter.format(cur_line, self.outfile)
109 no_format_mode = False
110 else:
111 traceback_informative_formatter.format(
112 cur_line, self.outfile
113 )
114 cur_line = []
115 elif text == " " and len(cur_line) == 0:
116 no_format_mode = True
117 cur_line.append((token, text))
118 else:
119 cur_line.append((token, text))
120 assert cur_line == [], cur_line
121
122
123def code_finished_will_parse(

Callers 5

writetbMethod · 0.95
version_help_textMethod · 0.45
__repr__Method · 0.45
__repr__Method · 0.45

Calls 3

formatMethod · 0.95
appendMethod · 0.80
BPythonFormatterClass · 0.70

Tested by 1