Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """ A collator for Mojo Application Manifests """ | 6 """ A collator for Mojo Application Manifests """ |
| 7 | 7 |
| 8 import argparse | 8 import argparse |
| 9 import json | 9 import json |
| 10 import shutil | 10 import shutil |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 description="Collate Mojo application manifests.") | 24 description="Collate Mojo application manifests.") |
| 25 parser.add_argument("--parent") | 25 parser.add_argument("--parent") |
| 26 parser.add_argument("--output") | 26 parser.add_argument("--output") |
| 27 parser.add_argument("--application-name") | 27 parser.add_argument("--application-name") |
| 28 args, children = parser.parse_known_args() | 28 args, children = parser.parse_known_args() |
| 29 | 29 |
| 30 parent = ParseJSONFile(args.parent) | 30 parent = ParseJSONFile(args.parent) |
| 31 if parent == None: | 31 if parent == None: |
| 32 return 1 | 32 return 1 |
| 33 | 33 |
| 34 parsed = urlparse.urlparse(parent['url']) | 34 app_path = parent['name'].split(':')[1] |
|
sky
2016/02/26 18:37:27
Error checking if split(':') returns a list of one
| |
| 35 if args.application_name != parsed.hostname: | 35 if args.application_name != app_path: |
| 36 raise ValueError("Application name '%s' specified in build file does not " \ | 36 raise ValueError("Application name '%s' specified in build file does not " \ |
| 37 "match application name '%s' specified in manifest." % | 37 "match application name '%s' specified in manifest." % |
| 38 (args.application_name, parsed.hostname)) | 38 (args.application_name, app_path)) |
| 39 | 39 |
| 40 applications = [] | 40 applications = [] |
| 41 for child in children: | 41 for child in children: |
| 42 application = ParseJSONFile(child) | 42 application = ParseJSONFile(child) |
| 43 if application == None: | 43 if application == None: |
| 44 return 1 | 44 return 1 |
| 45 applications.append(application) | 45 applications.append(application) |
| 46 | 46 |
| 47 if len(applications) > 0: | 47 if len(applications) > 0: |
| 48 parent['applications'] = applications | 48 parent['applications'] = applications |
| 49 | 49 |
| 50 with open(args.output, 'w') as output_file: | 50 with open(args.output, 'w') as output_file: |
| 51 json.dump(parent, output_file) | 51 json.dump(parent, output_file) |
| 52 | 52 |
| 53 return 0 | 53 return 0 |
| 54 | 54 |
| 55 if __name__ == "__main__": | 55 if __name__ == "__main__": |
| 56 sys.exit(main()) | 56 sys.exit(main()) |
| OLD | NEW |