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

Method maybe_indent

Tools/cases_generator/cwriter.py:54–73  ·  view source on GitHub ↗
(self, txt: str)

Source from the content-addressed store, hash-verified

52 self.indents.pop()
53
54 def maybe_indent(self, txt: str) -> None:
55 parens = txt.count("(") - txt.count(")")
56 if parens > 0:
57 if self.last_token:
58 offset = self.last_token.end_column - 1
59 if offset <= self.indents[-1] or offset > 40:
60 offset = self.indents[-1] + 4
61 else:
62 offset = self.indents[-1] + 4
63 self.indents.append(offset)
64 if is_label(txt):
65 self.indents.append(self.indents[-1] + 4)
66 else:
67 braces = txt.count("{") - txt.count("}")
68 if braces > 0:
69 assert braces == 1
70 if 'extern "C"' in txt:
71 self.indents.append(self.indents[-1])
72 else:
73 self.indents.append(self.indents[-1] + 4)
74
75 def emit_text(self, txt: str) -> None:
76 self.out.write(txt)

Callers 2

emit_tokenMethod · 0.95
emit_strMethod · 0.95

Calls 3

is_labelFunction · 0.85
countMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected