OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os.path | 5 import os.path |
6 import sys | 6 import sys |
7 import optparse | 7 import optparse |
8 import collections | 8 import collections |
9 import functools | 9 import functools |
10 try: | 10 try: |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if command["name"] == "disable": | 338 if command["name"] == "disable": |
339 return True | 339 return True |
340 return False | 340 return False |
341 | 341 |
342 | 342 |
343 def read_protocol_file(file_name, json_api): | 343 def read_protocol_file(file_name, json_api): |
344 input_file = open(file_name, "r") | 344 input_file = open(file_name, "r") |
345 json_string = input_file.read() | 345 json_string = input_file.read() |
346 input_file.close() | 346 input_file.close() |
347 parsed_json = json.loads(json_string) | 347 parsed_json = json.loads(json_string) |
| 348 version = parsed_json["version"]["major"] + "." + parsed_json["version"]["mi
nor"] |
348 domains = [] | 349 domains = [] |
349 for domain in parsed_json["domains"]: | 350 for domain in parsed_json["domains"]: |
350 domains.append(domain["domain"]) | 351 domains.append(domain["domain"]) |
| 352 domain["version"] = version |
351 json_api["domains"] += parsed_json["domains"] | 353 json_api["domains"] += parsed_json["domains"] |
352 return domains | 354 return domains |
353 | 355 |
354 | 356 |
355 class Protocol(object): | 357 class Protocol(object): |
356 def __init__(self): | 358 def __init__(self): |
357 self.json_api = {} | 359 self.json_api = {} |
358 self.generate_domains = [] | 360 self.generate_domains = [] |
359 self.imported_domains = [] | 361 self.imported_domains = [] |
360 | 362 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 if up_to_date: | 476 if up_to_date: |
475 sys.exit() | 477 sys.exit() |
476 | 478 |
477 for file_name, content in outputs.iteritems(): | 479 for file_name, content in outputs.iteritems(): |
478 out_file = open(file_name, "w") | 480 out_file = open(file_name, "w") |
479 out_file.write(content) | 481 out_file.write(content) |
480 out_file.close() | 482 out_file.close() |
481 | 483 |
482 | 484 |
483 main() | 485 main() |
OLD | NEW |