Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # This Source Code Form is subject to the terms of the Mozilla Public | 1 # This Source Code Form is subject to the terms of the Mozilla Public |
2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
4 | 4 |
5 import base64 | 5 import base64 |
6 import hashlib | 6 import hashlib |
7 import json | 7 import json |
8 import mimetypes | 8 import mimetypes |
9 import os | 9 import os |
10 import zipfile | 10 import zipfile |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 | 78 |
79 def create_appx_manifest(params, files, release_build=False): | 79 def create_appx_manifest(params, files, release_build=False): |
80 """Create AppxManifest.xml.""" | 80 """Create AppxManifest.xml.""" |
81 params = dict(params) | 81 params = dict(params) |
82 metadata = params['metadata'] | 82 metadata = params['metadata'] |
83 w = params['windows_version'] = {} | 83 w = params['windows_version'] = {} |
84 w['min'], w['max'] = metadata.get('compat', 'windows').split('/') | 84 w['min'], w['max'] = metadata.get('compat', 'windows').split('/') |
85 params.update(metadata.items('general')) | 85 params.update(metadata.items('general')) |
86 params['version'] = pad_version(params['version']) | 86 params['version'] = pad_version(params['version']) |
87 | 87 |
88 metadata_id_suffix = 'release' if release_build else 'devbuild' | 88 metadata_suffix = 'release' if release_build else 'devbuild' |
89 app_extension_id = 'extension_id_' + metadata_id_suffix | 89 app_extension_id = 'extension_id_' +metadata_suffix |
90 if metadata.has_option('general', app_extension_id): | 90 if metadata.has_option('general', app_extension_id): |
91 params['app_extension_id'] = metadata.get('general', app_extension_id) | 91 params['app_extension_id'] = metadata.get('general', app_extension_id) |
92 else: | 92 else: |
93 params['app_extension_id'] = 'EdgeExtension' | 93 params['app_extension_id'] = 'EdgeExtension' |
94 | 94 |
95 app_id = 'app_id_' + metadata_id_suffix | 95 app_id = 'app_id_' + metadata_suffix |
96 if not metadata.has_option('general', app_id): | |
97 raise KeyError(app_id + ' key not found') | |
Sebastian Noack
2017/02/08 07:17:16
Do we even need to specifically handle that case?
Oleksandr
2017/02/08 07:47:31
Done.
| |
98 params['app_id'] = metadata.get('general', app_id) | 96 params['app_id'] = metadata.get('general', app_id) |
99 | 97 |
100 translation = load_translation(files, defaultLocale) | 98 translation = load_translation(files, defaultLocale) |
101 name_key = 'name' if release_build else 'name_devbuild' | 99 name_key = 'name' if release_build else 'name_devbuild' |
102 params['display_name'] = translation[name_key]['message'] | 100 params['display_name'] = translation[name_key]['message'] |
103 params['description'] = translation['description']['message'] | 101 params['description'] = translation['description']['message'] |
104 | 102 |
105 for size in ['44', '50', '150']: | 103 for size in ['44', '50', '150']: |
106 path = '{}/logo_{}.png'.format(ASSETS_DIR, size) | 104 path = '{}/logo_{}.png'.format(ASSETS_DIR, size) |
107 if path not in files: | 105 if path not in files: |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 if metadata.has_section('appx_assets'): | 191 if metadata.has_section('appx_assets'): |
194 for name, path in metadata.items('appx_assets'): | 192 for name, path in metadata.items('appx_assets'): |
195 path = os.path.join(baseDir, path) | 193 path = os.path.join(baseDir, path) |
196 files.read(path, '{}/{}'.format(ASSETS_DIR, name)) | 194 files.read(path, '{}/{}'.format(ASSETS_DIR, name)) |
197 | 195 |
198 files[MANIFEST] = create_appx_manifest(params, files, releaseBuild) | 196 files[MANIFEST] = create_appx_manifest(params, files, releaseBuild) |
199 files[BLOCKMAP] = create_appx_blockmap(files) | 197 files[BLOCKMAP] = create_appx_blockmap(files) |
200 files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP]) | 198 files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP]) |
201 | 199 |
202 files.zip(outfile, compression=zipfile.ZIP_STORED) | 200 files.zip(outfile, compression=zipfile.ZIP_STORED) |
LEFT | RIGHT |