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

Method format

bpython/formatter.py:117–133  ·  view source on GitHub ↗
(
        self,
        tokensource: Iterable[MutableMapping[_TokenType, str]],
        outfile: TextIO,
    )

Source from the content-addressed store, hash-verified

115 super().__init__(**options)
116
117 def format(
118 self,
119 tokensource: Iterable[MutableMapping[_TokenType, str]],
120 outfile: TextIO,
121 ) -> None:
122 o: str = ""
123 for token, text in tokensource:
124 if text == "\n":
125 continue
126
127 while token not in self.f_strings:
128 if token.parent is None:
129 break
130 else:
131 token = token.parent
132 o += f"{self.f_strings[token]}\x03{text}\x04"
133 outfile.write(o.rstrip())
134
135
136# vim: sw=4 ts=4 sts=4 ai et

Callers 4

__init__Method · 0.45
version_bannerFunction · 0.45
copyright_bannerFunction · 0.45

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected