| OLD | NEW |
| 1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
| 2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
| 3 | 3 |
| 4 # Copyright 2015 Google Inc. All Rights Reserved. | 4 # Copyright 2015 Google Inc. All Rights Reserved. |
| 5 # | 5 # |
| 6 # Licensed under the Apache License, Version 2.0 (the "License"); | 6 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 # you may not use this file except in compliance with the License. | 7 # you may not use this file except in compliance with the License. |
| 8 # You may obtain a copy of the License at | 8 # You may obtain a copy of the License at |
| 9 # | 9 # |
| 10 # http://www.apache.org/licenses/LICENSE-2.0 | 10 # http://www.apache.org/licenses/LICENSE-2.0 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 | 455 |
| 456 def add_app_info(output_dir, chrome_app_manifest): | 456 def add_app_info(output_dir, chrome_app_manifest): |
| 457 """Adds an app info script, containing metadata, to a web app. | 457 """Adds an app info script, containing metadata, to a web app. |
| 458 | 458 |
| 459 Args: | 459 Args: |
| 460 output_dir: Path to web app to add app info script to. | 460 output_dir: Path to web app to add app info script to. |
| 461 chrome_app_manifest: Chrome App manifest dictionary. | 461 chrome_app_manifest: Chrome App manifest dictionary. |
| 462 """ | 462 """ |
| 463 logging.debug('Generating app info script.') | 463 logging.debug('Generating app info script.') |
| 464 js_manifest = json.dumps(chrome_app_manifest, sort_keys=True, indent=2, | 464 js_manifest = json.dumps(chrome_app_manifest, sort_keys=True, indent=2, |
| 465 separators=(',', ': ')).replace('"', "'") | 465 separators=(',', ': ')) |
| 466 app_info_js = ('chrome.caterpillar.manifest = {manifest};\n').format( | 466 app_info_js = ('chrome.caterpillar.manifest = {manifest};\n').format( |
| 467 manifest=js_manifest) | 467 manifest=js_manifest) |
| 468 app_info_path = os.path.join(output_dir, INFO_SCRIPT_NAME) | 468 app_info_path = os.path.join(output_dir, INFO_SCRIPT_NAME) |
| 469 logging.debug('Writing app info script to `%s`.', app_info_path) | 469 logging.debug('Writing app info script to `%s`.', app_info_path) |
| 470 with open(app_info_path, 'w') as app_info_file: | 470 with open(app_info_path, 'w') as app_info_file: |
| 471 app_info_file.write(app_info_js.encode('utf-8')) | 471 app_info_file.write(app_info_js.encode('utf-8')) |
| 472 | 472 |
| 473 | 473 |
| 474 class InstallationError(Exception): | 474 class InstallationError(Exception): |
| 475 """Exception raised when a dependency fails to install.""" | 475 """Exception raised when a dependency fails to install.""" |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 configuration.generate_and_save(args.output, args.interactive) | 854 configuration.generate_and_save(args.output, args.interactive) |
| 855 | 855 |
| 856 elif args.mode == 'convert': | 856 elif args.mode == 'convert': |
| 857 config = configuration.load(args.config) | 857 config = configuration.load(args.config) |
| 858 convert_app(args.input, args.output, config, handler.captured_warnings, | 858 convert_app(args.input, args.output, config, handler.captured_warnings, |
| 859 args.force) | 859 args.force) |
| 860 | 860 |
| 861 | 861 |
| 862 if __name__ == '__main__': | 862 if __name__ == '__main__': |
| 863 sys.exit(main()) | 863 sys.exit(main()) |
| OLD | NEW |