|
45 | 45 | #
|
46 | 46 | # Adding --show_changes to the command line prints out a list of valid public API changes.
|
47 | 47 |
|
| 48 | +from __future__ import print_function |
48 | 49 | import copy
|
49 | 50 | import os.path
|
50 | 51 | import optparse
|
51 | 52 | import sys
|
52 | 53 |
|
| 54 | +import pdl |
| 55 | + |
53 | 56 | try:
|
54 | 57 | import json
|
55 | 58 | except ImportError:
|
@@ -166,6 +169,11 @@ def compare_types(context, kind, type_1, type_2, types_map_1, types_map_2, depth
|
166 | 169 | base_type_1 = type_1["type"]
|
167 | 170 | base_type_2 = type_2["type"]
|
168 | 171 |
|
| 172 | + # Binary and string have the same wire representation in JSON. |
| 173 | + if ((base_type_1 == "string" and base_type_2 == "binary") or |
| 174 | + (base_type_2 == "string" and base_type_1 == "binary")): |
| 175 | + return |
| 176 | + |
169 | 177 | if base_type_1 != base_type_2:
|
170 | 178 | errors.append("%s: %s base type mismatch, '%s' vs '%s'" % (context, kind, base_type_1, base_type_2))
|
171 | 179 | elif base_type_1 == "object":
|
@@ -228,8 +236,8 @@ def load_schema(file_name, domains):
|
228 | 236 | if not os.path.isfile(file_name):
|
229 | 237 | return
|
230 | 238 | input_file = open(file_name, "r")
|
231 |
| - json_string = input_file.read() |
232 |
| - parsed_json = json.loads(json_string) |
| 239 | + parsed_json = pdl.loads(input_file.read(), file_name) |
| 240 | + input_file.close() |
233 | 241 | domains += parsed_json["domains"]
|
234 | 242 | return parsed_json["version"]
|
235 | 243 |
|
@@ -422,6 +430,7 @@ def load_domains_and_baselines(file_name, domains, baseline_domains):
|
422 | 430 | version = load_schema(os.path.normpath(file_name), domains)
|
423 | 431 | suffix = "-%s.%s.json" % (version["major"], version["minor"])
|
424 | 432 | baseline_file = file_name.replace(".json", suffix)
|
| 433 | + baseline_file = file_name.replace(".pdl", suffix) |
425 | 434 | load_schema(os.path.normpath(baseline_file), baseline_domains)
|
426 | 435 | return version
|
427 | 436 |
|
@@ -467,9 +476,9 @@ def main():
|
467 | 476 | if arg_options.show_changes:
|
468 | 477 | changes = compare_schemas(domains, baseline_domains, True)
|
469 | 478 | if len(changes) > 0:
|
470 |
| - print " Public changes since %s:" % version |
| 479 | + print(" Public changes since %s:" % version) |
471 | 480 | for change in changes:
|
472 |
| - print " %s" % change |
| 481 | + print(" %s" % change) |
473 | 482 |
|
474 | 483 | if arg_options.stamp:
|
475 | 484 | with open(arg_options.stamp, 'a') as _:
|
|
0 commit comments