diff options
Diffstat (limited to 'tools/gyp/tools/pretty_gyp.py')
-rwxr-xr-x | tools/gyp/tools/pretty_gyp.py | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/tools/gyp/tools/pretty_gyp.py b/tools/gyp/tools/pretty_gyp.py index d5736bbd4a..d01c692edc 100755 --- a/tools/gyp/tools/pretty_gyp.py +++ b/tools/gyp/tools/pretty_gyp.py @@ -6,6 +6,8 @@ """Pretty-prints the contents of a GYP file.""" +from __future__ import print_function + import sys import re @@ -118,23 +120,24 @@ def prettyprint_input(lines): basic_offset = 2 last_line = "" for line in lines: - line = line.strip('\r\n\t ') # Otherwise doesn't strip \r on Unix. - if len(line) > 0: - brace_diff = 0 - if not COMMENT_RE.match(line): + if COMMENT_RE.match(line): + print(line) + else: + line = line.strip('\r\n\t ') # Otherwise doesn't strip \r on Unix. + if len(line) > 0: (brace_diff, after) = count_braces(line) - if brace_diff != 0: - if after: - print " " * (basic_offset * indent) + line - indent += brace_diff + if brace_diff != 0: + if after: + print(" " * (basic_offset * indent) + line) + indent += brace_diff + else: + indent += brace_diff + print(" " * (basic_offset * indent) + line) else: - indent += brace_diff - print " " * (basic_offset * indent) + line + print(" " * (basic_offset * indent) + line) else: - print " " * (basic_offset * indent) + line - else: - print "" - last_line = line + print("") + last_line = line def main(): |