3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 """Inlines all module.json files into modules.js."""
15 def read_file(filename):
16 with open(filename, 'rt') as file:
20 def build_modules(module_jsons):
22 for json_filename in module_jsons:
23 if not path.exists(json_filename):
25 module_name = path.basename(path.dirname(json_filename))
26 json = read_file(json_filename).replace('{', '{"name":"%s",' % module_name, 1)
28 return ','.join(result)
32 input_filename = argv[1]
33 output_filename = argv[2]
34 module_jsons = argv[3:]
36 with open(output_filename, 'w') as output_file:
37 output_file.write('var allDescriptors=[%s];' % build_modules(module_jsons))
40 if __name__ == '__main__':
41 sys.exit(main(sys.argv))