MCPcopy Index your code
hub / github.com/python/cpython / __init__

Method __init__

Tools/patchcheck/reindent.py:176–199  ·  view source on GitHub ↗
(self, f)

Source from the content-addressed store, hash-verified

174class Reindenter:
175
176 def __init__(self, f):
177 self.find_stmt = 1 # next token begins a fresh stmt?
178 self.level = 0 # current indent level
179
180 # Raw file lines.
181 self.raw = f.readlines()
182
183 # File lines, rstripped & tab-expanded. Dummy at start is so
184 # that we can use tokenize's 1-based line numbering easily.
185 # Note that a line is all-blank iff it's "\n".
186 self.lines = [_rstrip(line).expandtabs() + "\n"
187 for line in self.raw]
188 self.lines.insert(0, None)
189 self.index = 1 # index into self.lines of next line
190
191 # List of (lineno, indentlevel) pairs, one for each stmt and
192 # comment line. indentlevel is -1 for comment lines, as a
193 # signal that tokenize doesn't know what to do about them;
194 # indeed, they're our headache!
195 self.stats = []
196
197 # Save the newlines found in the file so they can be used to
198 # create output without mutating the newlines.
199 self.newlines = f.newlines
200
201 def run(self):
202 tokens = tokenize.generate_tokens(self.getline)

Callers

nothing calls this directly

Calls 4

_rstripFunction · 0.85
readlinesMethod · 0.45
expandtabsMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected