| 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: |
| 11 Output of generate_idl_diff.py. The json file contains a dictionary | 11 Output of generate_idl_diff.py. The json file contains a dictionary |
| 12 that represents a diff between two different Chromium versions. The | 12 that represents a diff between two different Chromium versions. The |
| 13 structure of the dictionary is like below. | 13 structure of the dictionary is like below. |
| 14 order: | 14 order: |
| 15 Specify how to sort. Either by "ALPHABET" or "TAG". | 15 Specify how to sort. Either by "ALPHABET" or "TAG". |
| 16 """ | 16 """ |
| 17 | 17 |
| 18 from collections import OrderedDict | 18 from collections import OrderedDict |
| 19 import json | |
| 20 import sys | 19 import sys |
| 21 | 20 |
| 22 from generate_idl_diff import load_json_file | 21 from webkitpy.bindings.generate_idl_diff import load_json_file |
| 23 from generate_idl_diff import EXTATTRIBUTES_AND_MEMBER_TYPES | 22 from webkitpy.bindings.generate_idl_diff import EXTATTRIBUTES_AND_MEMBER_TYPES |
| 24 from generate_idl_diff import DIFF_TAG | 23 from webkitpy.bindings.generate_idl_diff import DIFF_TAG |
| 25 from generate_idl_diff import DIFF_TAG_ADDED | 24 from webkitpy.bindings.generate_idl_diff import DIFF_TAG_ADDED |
| 26 from generate_idl_diff import DIFF_TAG_DELETED | 25 from webkitpy.bindings.generate_idl_diff import DIFF_TAG_DELETED |
| 27 | 26 |
| 28 | 27 |
| 28 # pylint: disable=W0105 |
| 29 """Refer to the explanation of generate_idl_diff.py's input files. | 29 """Refer to the explanation of generate_idl_diff.py's input files. |
| 30 The deffference between the input structure of generate_idl_diff.py and | 30 The deffference between the input structure of generate_idl_diff.py and |
| 31 that of print_diff.py is whether diffing tags are included or not. | 31 that of print_diff.py is whether diffing tags are included or not. |
| 32 {'Interface': { | 32 {'Interface': { |
| 33 'diff_tag': 'deleted' | 33 'diff_tag': 'deleted' |
| 34 'ExtAttributes': [{'Name': '...' | 34 'ExtAttributes': [{'Name': '...' |
| 35 'diff_tag': 'deleted'}, | 35 'diff_tag': 'deleted'}, |
| 36 ..., | 36 ..., |
| 37 ], | 37 ], |
| 38 'Consts': [{'Type': '...', | 38 'Consts': [{'Type': '...', |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 [names of deleted "interface"s | 183 [names of deleted "interface"s |
| 184 -> names of added "interface"s | 184 -> names of added "interface"s |
| 185 -> names of other "interface"s] | 185 -> names of other "interface"s] |
| 186 Args: | 186 Args: |
| 187 interfaces: "interface" objects. | 187 interfaces: "interface" objects. |
| 188 Returns: | 188 Returns: |
| 189 A list of sorted interface names | 189 A list of sorted interface names |
| 190 """ | 190 """ |
| 191 interface_list = interfaces.values() | 191 interface_list = interfaces.values() |
| 192 removed, added, unspecified = group_by_tag(interface_list) | 192 removed, added, unspecified = group_by_tag(interface_list) |
| 193 # pylint: disable=W0110 |
| 193 removed = map(lambda interface: interface['Name'], removed) | 194 removed = map(lambda interface: interface['Name'], removed) |
| 195 # pylint: disable=W0110 |
| 194 added = map(lambda interface: interface['Name'], added) | 196 added = map(lambda interface: interface['Name'], added) |
| 197 # pylint: disable=W0110 |
| 195 unspecified = map(lambda interface: interface['Name'], unspecified) | 198 unspecified = map(lambda interface: interface['Name'], unspecified) |
| 196 sorted_interface_names = removed + added + unspecified | 199 sorted_interface_names = removed + added + unspecified |
| 197 return sorted_interface_names | 200 return sorted_interface_names |
| 198 | 201 |
| 199 | 202 |
| 200 def sort_members_by_tags(interface): | 203 def sort_members_by_tags(interface): |
| 201 """Sort members of a given interface in the order of diffing tags. | 204 """Sort members of a given interface in the order of diffing tags. |
| 202 Args: | 205 Args: |
| 203 An "interface" object | 206 An "interface" object |
| 204 Returns: | 207 Returns: |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 else: | 427 else: |
| 425 print_usage() | 428 print_usage() |
| 426 exit(1) | 429 exit(1) |
| 427 sorted_diff = sort_func(diff) | 430 sorted_diff = sort_func(diff) |
| 428 out = Colorize(sys.stdout) | 431 out = Colorize(sys.stdout) |
| 429 print_diff(sorted_diff, out) | 432 print_diff(sorted_diff, out) |
| 430 | 433 |
| 431 | 434 |
| 432 if __name__ == '__main__': | 435 if __name__ == '__main__': |
| 433 main(sys.argv[1:]) | 436 main(sys.argv[1:]) |
| OLD | NEW |