| 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 22 matching lines...) Expand all Loading... |
| 33 assert isinstance(left[k], list) | 33 assert isinstance(left[k], list) |
| 34 left[k].extend(v) | 34 left[k].extend(v) |
| 35 else: | 35 else: |
| 36 raise "Refusing to merge conflicting non-collection values." | 36 raise "Refusing to merge conflicting non-collection values." |
| 37 return left | 37 return left |
| 38 | 38 |
| 39 | 39 |
| 40 def MergeBaseManifest(parent, base): | 40 def MergeBaseManifest(parent, base): |
| 41 MergeDicts(parent["capabilities"], base["capabilities"]) | 41 MergeDicts(parent["capabilities"], base["capabilities"]) |
| 42 | 42 |
| 43 if "applications" in base: |
| 44 if "applications" not in parent: |
| 45 parent["applications"] = [] |
| 46 parent["applications"].extend(base["applications"]) |
| 47 |
| 48 if "process-group" in base: |
| 49 parent["process-group"] = base["process-group"] |
| 50 |
| 43 | 51 |
| 44 def main(): | 52 def main(): |
| 45 parser = argparse.ArgumentParser( | 53 parser = argparse.ArgumentParser( |
| 46 description="Collate Mojo application manifests.") | 54 description="Collate Mojo application manifests.") |
| 47 parser.add_argument("--parent") | 55 parser.add_argument("--parent") |
| 48 parser.add_argument("--output") | 56 parser.add_argument("--output") |
| 49 parser.add_argument("--application-name") | 57 parser.add_argument("--application-name") |
| 50 parser.add_argument("--base-manifest", default=None) | 58 parser.add_argument("--base-manifest", default=None) |
| 51 args, children = parser.parse_known_args() | 59 args, children = parser.parse_known_args() |
| 52 | 60 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 80 if len(applications) > 0: | 88 if len(applications) > 0: |
| 81 parent['applications'] = applications | 89 parent['applications'] = applications |
| 82 | 90 |
| 83 with open(args.output, 'w') as output_file: | 91 with open(args.output, 'w') as output_file: |
| 84 json.dump(parent, output_file) | 92 json.dump(parent, output_file) |
| 85 | 93 |
| 86 return 0 | 94 return 0 |
| 87 | 95 |
| 88 if __name__ == "__main__": | 96 if __name__ == "__main__": |
| 89 sys.exit(main()) | 97 sys.exit(main()) |
| OLD | NEW |