| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Print a diff generated by generate_idl_diff.py. | 6 """Print a diff generated by generate_idl_diff.py. |
| 7 Before printing, sort the diff in the alphabetical order or the order of | 7 Before printing, sort the diff in the alphabetical order or the order of |
| 8 diffing tags. | 8 diffing tags. |
| 9 Usage: print_idl_diff.py diff_file.json order | 9 Usage: print_idl_diff.py diff_file.json order |
| 10 diff.json: | 10 diff.json: |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 BLACK = 30 | 108 BLACK = 30 |
| 109 RED = 31 | 109 RED = 31 |
| 110 GREEN = 32 | 110 GREEN = 32 |
| 111 YELLOW = 33 | 111 YELLOW = 33 |
| 112 COLORS = (BLACK, RED, GREEN, YELLOW) | 112 COLORS = (BLACK, RED, GREEN, YELLOW) |
| 113 | 113 |
| 114 def __init__(self, out): | 114 def __init__(self, out): |
| 115 self.out = out | 115 self.out = out |
| 116 | 116 |
| 117 def reset_color(self): | 117 def reset_color(self): |
| 118 """Reset text's color to default. | 118 """Reset text's color to default.""" |
| 119 """ | |
| 120 self.out.write('\033[0m') | 119 self.out.write('\033[0m') |
| 121 | 120 |
| 122 def change_color(self, color): | 121 def change_color(self, color): |
| 123 """Change text's color by specifing arguments. | 122 """Change text's color by specifing arguments. |
| 124 Args: | 123 Args: |
| 125 color: A new color to change. It should be one of |COLORS|. | 124 color: A new color to change. It should be one of |COLORS|. |
| 126 """ | 125 """ |
| 127 if color in self.COLORS: | 126 if color in self.COLORS: |
| 128 self.out.write('\033[' + str(color) + 'm') | 127 self.out.write('\033[' + str(color) + 'm') |
| 129 else: | 128 else: |
| 130 raise Exception('Unsupported color.') | 129 raise Exception('Unsupported color.') |
| 131 | 130 |
| 132 def writeln(self, string): | 131 def writeln(self, string): |
| 133 """Print text with a line-break. | 132 """Print text with a line-break.""" |
| 134 """ | |
| 135 self.out.write(string + '\n') | 133 self.out.write(string + '\n') |
| 136 | 134 |
| 137 def write(self, string): | 135 def write(self, string): |
| 138 """Print text without a line-break. | 136 """Print text without a line-break.""" |
| 139 """ | |
| 140 self.out.write(string) | 137 self.out.write(string) |
| 141 | 138 |
| 142 | 139 |
| 143 def sort_member_types(interface): | 140 def sort_member_types(interface): |
| 144 """Sort the members in the order of EXTATTRIBUTES_AND_MEMBER_TYPES. | 141 """Sort the members in the order of EXTATTRIBUTES_AND_MEMBER_TYPES. |
| 145 Args: | 142 Args: |
| 146 interface: An "interface" object | 143 interface: An "interface" object |
| 147 Returns: | 144 Returns: |
| 148 A sorted "interface" object | 145 A sorted "interface" object |
| 149 """ | 146 """ |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 else: | 424 else: |
| 428 print_usage() | 425 print_usage() |
| 429 exit(1) | 426 exit(1) |
| 430 sorted_diff = sort_func(diff) | 427 sorted_diff = sort_func(diff) |
| 431 out = Colorize(sys.stdout) | 428 out = Colorize(sys.stdout) |
| 432 print_diff(sorted_diff, out) | 429 print_diff(sorted_diff, out) |
| 433 | 430 |
| 434 | 431 |
| 435 if __name__ == '__main__': | 432 if __name__ == '__main__': |
| 436 main(sys.argv[1:]) | 433 main(sys.argv[1:]) |
| OLD | NEW |