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] |
35 if args.application_name != parsed.hostname: | 35 if app_path.startswith('//'): |
| 36 raise ValueError("Application name path component '%s' must not start " \ |
| 37 "with //" % app_path) |
| 38 |
| 39 if args.application_name != app_path: |
36 raise ValueError("Application name '%s' specified in build file does not " \ | 40 raise ValueError("Application name '%s' specified in build file does not " \ |
37 "match application name '%s' specified in manifest." % | 41 "match application name '%s' specified in manifest." % |
38 (args.application_name, parsed.hostname)) | 42 (args.application_name, app_path)) |
39 | 43 |
40 applications = [] | 44 applications = [] |
41 for child in children: | 45 for child in children: |
42 application = ParseJSONFile(child) | 46 application = ParseJSONFile(child) |
43 if application == None: | 47 if application == None: |
44 return 1 | 48 return 1 |
45 applications.append(application) | 49 applications.append(application) |
46 | 50 |
47 if len(applications) > 0: | 51 if len(applications) > 0: |
48 parent['applications'] = applications | 52 parent['applications'] = applications |
49 | 53 |
50 with open(args.output, 'w') as output_file: | 54 with open(args.output, 'w') as output_file: |
51 json.dump(parent, output_file) | 55 json.dump(parent, output_file) |
52 | 56 |
53 return 0 | 57 return 0 |
54 | 58 |
55 if __name__ == "__main__": | 59 if __name__ == "__main__": |
56 sys.exit(main()) | 60 sys.exit(main()) |
OLD | NEW |