|
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__ importprint_function |
48 | 49 | importcopy |
49 | 50 | importos.path |
50 | 51 | importoptparse |
51 | 52 | importsys |
52 | 53 |
|
| 54 | +importpdl |
| 55 | + |
53 | 56 | try: |
54 | 57 | importjson |
55 | 58 | exceptImportError: |
@@ -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"andbase_type_2=="binary") or |
| 174 | + (base_type_2=="string"andbase_type_1=="binary")): |
| 175 | +return |
| 176 | + |
169 | 177 | ifbase_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 | elifbase_type_1=="object": |
@@ -228,8 +236,8 @@ def load_schema(file_name, domains): |
228 | 236 | ifnotos.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 | returnparsed_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 | returnversion |
427 | 436 |
|
@@ -467,9 +476,9 @@ def main(): |
467 | 476 | ifarg_options.show_changes: |
468 | 477 | changes=compare_schemas(domains, baseline_domains, True) |
469 | 478 | iflen(changes) >0: |
470 | | -print" Public changes since %s:"%version |
| 479 | +print(" Public changes since %s:"%version) |
471 | 480 | forchangeinchanges: |
472 | | -print" %s"%change |
| 481 | +print(" %s"%change) |
473 | 482 |
|
474 | 483 | ifarg_options.stamp: |
475 | 484 | withopen(arg_options.stamp, 'a') as_: |
|
0 commit comments