OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 Google Inc. All rights reserved. | 2 # Copyright (c) 2011 Google Inc. All rights reserved. |
3 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 types[obj[key]] = obj | 222 types[obj[key]] = obj |
223 else: | 223 else: |
224 normalize_types(value, domain_name, types) | 224 normalize_types(value, domain_name, types) |
225 | 225 |
226 | 226 |
227 def load_schema(file, domains): | 227 def load_schema(file, domains): |
228 if not os.path.isfile(file): | 228 if not os.path.isfile(file): |
229 return | 229 return |
230 input_file = open(file, "r") | 230 input_file = open(file, "r") |
231 json_string = input_file.read() | 231 json_string = input_file.read() |
232 parsed_json = json.loads(json_string, object_pairs_hook=collections.OrderedD
ict) | 232 parsed_json = json.loads(json_string) |
233 domains += parsed_json["domains"] | 233 domains += parsed_json["domains"] |
234 return parsed_json["version"] | 234 return parsed_json["version"] |
235 | 235 |
236 | 236 |
237 def self_test(): | 237 def self_test(): |
238 def create_test_schema_1(): | 238 def create_test_schema_1(): |
239 return [ | 239 return [ |
240 { | 240 { |
241 "domain": "Network", | 241 "domain": "Network", |
242 "types": [ | 242 "types": [ |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 if len(changes) > 0: | 470 if len(changes) > 0: |
471 print " Public changes since %s:" % version | 471 print " Public changes since %s:" % version |
472 for change in changes: | 472 for change in changes: |
473 print " %s" % change | 473 print " %s" % change |
474 | 474 |
475 json.dump({"version": version, "domains": domains}, output_file, indent=4, s
ort_keys=False, separators=(',', ': ')) | 475 json.dump({"version": version, "domains": domains}, output_file, indent=4, s
ort_keys=False, separators=(',', ': ')) |
476 output_file.close() | 476 output_file.close() |
477 | 477 |
478 if __name__ == '__main__': | 478 if __name__ == '__main__': |
479 sys.exit(main()) | 479 sys.exit(main()) |
OLD | NEW |