| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 | 65 |
| 66 | 66 |
| 67 def load_translation(files, locale): | 67 def load_translation(files, locale): |
| 68 """Load translation strings for locale from files.""" | 68 """Load translation strings for locale from files.""" |
| 69 path = '{}/_locales/{}/messages.json'.format(EXTENSION_DIR, locale) | 69 path = '{}/_locales/{}/messages.json'.format(EXTENSION_DIR, locale) |
| 70 return json.loads(files[path]) | 70 return json.loads(files[path]) |
| 71 | 71 |
| 72 | 72 |
| 73 def fix_version(version): | 73 def fix_version(version): |
| 74 """Prepare a version number for usage in AppxManifest.xml. | 74 """Prepare a version number for usage in AppxManifest.xml. |
| 75 | 75 |
|
tlucas
2017/09/12 21:38:08
Flake8 fails on this line:
./packagerEdge.py:75:1:
Sebastian Noack
2017/09/12 21:41:18
Argh, sorry, I forgot to run tox/flake8, again. Ap
| |
| 76 As required by the Windows Store, the returned version string has | 76 As required by the Windows Store, the returned version string has |
| 77 four components with the last component being zero (e.g. 12.34.56.0). | 77 four components with the last component being zero (e.g. 12.34.56.0). |
| 78 """ | 78 """ |
| 79 components = version.split('.')[:3] | 79 components = version.split('.')[:3] |
| 80 components.extend(['0'] * (4 - len(components))) | 80 components.extend(['0'] * (4 - len(components))) |
| 81 return '.'.join(components) | 81 return '.'.join(components) |
| 82 | 82 |
| 83 | 83 |
| 84 def create_appx_manifest(params, files, release_build=False): | 84 def create_appx_manifest(params, files, release_build=False): |
| 85 """Create AppxManifest.xml.""" | 85 """Create AppxManifest.xml.""" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 if metadata.has_section('appx_assets'): | 190 if metadata.has_section('appx_assets'): |
| 191 for name, path in metadata.items('appx_assets'): | 191 for name, path in metadata.items('appx_assets'): |
| 192 path = os.path.join(baseDir, path) | 192 path = os.path.join(baseDir, path) |
| 193 files.read(path, '{}/{}'.format(ASSETS_DIR, name)) | 193 files.read(path, '{}/{}'.format(ASSETS_DIR, name)) |
| 194 | 194 |
| 195 files[MANIFEST] = create_appx_manifest(params, files, releaseBuild) | 195 files[MANIFEST] = create_appx_manifest(params, files, releaseBuild) |
| 196 files[BLOCKMAP] = create_appx_blockmap(files) | 196 files[BLOCKMAP] = create_appx_blockmap(files) |
| 197 files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP]) | 197 files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP]) |
| 198 | 198 |
| 199 files.zip(outfile, compression=zipfile.ZIP_STORED) | 199 files.zip(outfile, compression=zipfile.ZIP_STORED) |
| LEFT | RIGHT |