OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 import os.path | |
7 import sys | |
8 | |
9 try: | |
10 import json | |
11 except ImportError: | |
12 import simplejson as json | |
13 | |
14 | |
15 def main(argv): | |
16 if len(argv) < 1: | |
17 sys.stderr.write("Usage: %s <protocol-1> [<protocol-2> [, <protocol-3>..
.]] <output-file>\n" % sys.argv[0]) | |
18 return 1 | |
19 | |
20 domains = [] | |
21 version = None | |
22 for protocol in argv[:-1]: | |
23 file_name = os.path.normpath(protocol) | |
24 if not os.path.isfile(file_name): | |
25 sys.stderr.write("Cannot find %s\n" % file_name) | |
26 return 1 | |
27 input_file = open(file_name, "r") | |
28 json_string = input_file.read() | |
29 parsed_json = json.loads(json_string) | |
30 domains += parsed_json["domains"] | |
31 version = parsed_json["version"] | |
32 | |
33 output_file = open(argv[-1], "w") | |
34 json.dump({"version": version, "domains": domains}, output_file, indent=4, s
ort_keys=False, separators=(',', ': ')) | |
35 output_file.close() | |
36 | |
37 | |
38 if __name__ == '__main__': | |
39 sys.exit(main(sys.argv[1:])) | |
OLD | NEW |