MCPcopy Create free account
hub / github.com/nodejs/node / prettyprint_input

Function prettyprint_input

tools/gyp/tools/pretty_gyp.py:116–137  ·  view source on GitHub ↗

Does the main work of indenting the input based on the brace counts.

(lines)

Source from the content-addressed store, hash-verified

114
115
116def prettyprint_input(lines):
117 """Does the main work of indenting the input based on the brace counts."""
118 indent = 0
119 basic_offset = 2
120 for line in lines:
121 if COMMENT_RE.match(line):
122 print(line)
123 else:
124 line = line.strip("\r\n\t ") # Otherwise doesn't strip \r on Unix.
125 if len(line) > 0:
126 (brace_diff, after) = count_braces(line)
127 if brace_diff != 0:
128 if after:
129 print(" " * (basic_offset * indent) + line)
130 indent += brace_diff
131 else:
132 indent += brace_diff
133 print(" " * (basic_offset * indent) + line)
134 else:
135 print(" " * (basic_offset * indent) + line)
136 else:
137 print()
138
139
140def main():

Callers 1

mainFunction · 0.85

Calls 3

count_bracesFunction · 0.85
matchMethod · 0.65
printFunction · 0.50

Tested by

no test coverage detected