Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: packagerEdge.py

Issue 29542744: Issue 5666 - Replace 4th component of version in AppxManifest.xml with 0 (Closed)
Patch Set: Created Sept. 12, 2017, 7:49 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/test_packagerEdge.py » ('j') | tests/test_packagerEdge.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 files = [_make_blockmap_entry(n, d) for n, d in files.items()] 63 files = [_make_blockmap_entry(n, d) for n, d in files.items()]
64 return template.render(files=files).encode('utf-8') 64 return template.render(files=files).encode('utf-8')
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 pad_version(version): 73 def fix_version(version):
74 """Make sure version number has 4 groups of digits.""" 74 """
75 groups = (version.split('.') + ['0', '0', '0'])[:4] 75 Prepares a version number for usage in AppxManifest.xml which requires
76 return '.'.join(groups) 76 four components with the last component being zero (e.g. 12.34.56.0).
tlucas 2017/09/12 21:24:18 You should use the imperative for docstrings, e.g.
Sebastian Noack 2017/09/12 21:35:45 Done.
77 """
78 components = version.split('.')[:3]
79 components.extend(['0'] * (4 - len(components)))
80 return '.'.join(components)
77 81
78 82
79 def create_appx_manifest(params, files, release_build=False): 83 def create_appx_manifest(params, files, release_build=False):
80 """Create AppxManifest.xml.""" 84 """Create AppxManifest.xml."""
81 params = dict(params) 85 params = dict(params)
82 metadata = params['metadata'] 86 metadata = params['metadata']
83 w = params['windows_version'] = {} 87 w = params['windows_version'] = {}
84 w['min'], w['max'] = metadata.get('compat', 'windows').split('/') 88 w['min'], w['max'] = metadata.get('compat', 'windows').split('/')
85 params['version'] = pad_version(params['version']) 89 params['version'] = fix_version(params['version'])
86 90
87 metadata_suffix = 'release' if release_build else 'devbuild' 91 metadata_suffix = 'release' if release_build else 'devbuild'
88 app_extension_id = 'extension_id_' + metadata_suffix 92 app_extension_id = 'extension_id_' + metadata_suffix
89 if metadata.has_option('general', app_extension_id): 93 if metadata.has_option('general', app_extension_id):
90 params['app_extension_id'] = metadata.get('general', app_extension_id) 94 params['app_extension_id'] = metadata.get('general', app_extension_id)
91 else: 95 else:
92 params['app_extension_id'] = 'EdgeExtension' 96 params['app_extension_id'] = 'EdgeExtension'
93 97
94 app_id = 'app_id_' + metadata_suffix 98 app_id = 'app_id_' + metadata_suffix
95 params['app_id'] = metadata.get('general', app_id) 99 params['app_id'] = metadata.get('general', app_id)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if metadata.has_section('appx_assets'): 189 if metadata.has_section('appx_assets'):
186 for name, path in metadata.items('appx_assets'): 190 for name, path in metadata.items('appx_assets'):
187 path = os.path.join(baseDir, path) 191 path = os.path.join(baseDir, path)
188 files.read(path, '{}/{}'.format(ASSETS_DIR, name)) 192 files.read(path, '{}/{}'.format(ASSETS_DIR, name))
189 193
190 files[MANIFEST] = create_appx_manifest(params, files, releaseBuild) 194 files[MANIFEST] = create_appx_manifest(params, files, releaseBuild)
191 files[BLOCKMAP] = create_appx_blockmap(files) 195 files[BLOCKMAP] = create_appx_blockmap(files)
192 files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP]) 196 files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP])
193 197
194 files.zip(outfile, compression=zipfile.ZIP_STORED) 198 files.zip(outfile, compression=zipfile.ZIP_STORED)
OLDNEW
« no previous file with comments | « no previous file | tests/test_packagerEdge.py » ('j') | tests/test_packagerEdge.py » ('J')

Powered by Google App Engine
This is Rietveld