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

Side by Side Diff: packagerEdge.py

Issue 29360043: Issue 4575 - Fix failing tests in buildtools (Closed)
Patch Set: Address comments on patch set 1 Created Nov. 30, 2016, 3:10 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 | releaseAutomation.py » ('j') | no next file with comments »
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 files['{}/{}'.format(EXTENSION_DIR, filename)] = files.pop(filename) 110 files['{}/{}'.format(EXTENSION_DIR, filename)] = files.pop(filename)
111 111
112 112
113 def create_content_types_map(filenames): 113 def create_content_types_map(filenames):
114 """Create [Content_Types].xml -- a mime type map.""" 114 """Create [Content_Types].xml -- a mime type map."""
115 params = {'defaults': {}, 'overrides': {}} 115 params = {'defaults': {}, 'overrides': {}}
116 overrides = { 116 overrides = {
117 BLOCKMAP: 'application/vnd.ms-appx.blockmap+xml', 117 BLOCKMAP: 'application/vnd.ms-appx.blockmap+xml',
118 MANIFEST: 'application/vnd.ms-appx.manifest+xml' 118 MANIFEST: 'application/vnd.ms-appx.manifest+xml'
119 } 119 }
120 types = mimetypes.MimeTypes()
121 types.add_type('application/octet-stream', '.otf')
120 for filename in filenames: 122 for filename in filenames:
121 ext = os.path.splitext(filename)[1] 123 ext = os.path.splitext(filename)[1]
122 if ext: 124 if ext:
123 content_type = mimetypes.guess_type(filename, strict=False)[0] 125 content_type = types.guess_type(filename, strict=False)[0]
124 if content_type is not None: 126 if content_type is not None:
125 params['defaults'][ext[1:]] = content_type 127 params['defaults'][ext[1:]] = content_type
126 if filename in overrides: 128 if filename in overrides:
127 params['overrides']['/' + filename] = overrides[filename] 129 params['overrides']['/' + filename] = overrides[filename]
128 content_types_template = _get_template_for(CONTENT_TYPES) 130 content_types_template = _get_template_for(CONTENT_TYPES)
129 return content_types_template.render(params).encode('utf-8') 131 return content_types_template.render(params).encode('utf-8')
130 132
131 133
132 def createBuild(baseDir, type='edge', outFile=None, # noqa: preserve API. 134 def createBuild(baseDir, type='edge', outFile=None, # noqa: preserve API.
133 buildNum=None, releaseBuild=False, keyFile=None, 135 buildNum=None, releaseBuild=False, keyFile=None,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 if metadata.has_section('appx_assets'): 176 if metadata.has_section('appx_assets'):
175 for name, path in metadata.items('appx_assets'): 177 for name, path in metadata.items('appx_assets'):
176 path = os.path.join(baseDir, path) 178 path = os.path.join(baseDir, path)
177 files.read(path, '{}/{}'.format(ASSETS_DIR, name)) 179 files.read(path, '{}/{}'.format(ASSETS_DIR, name))
178 180
179 files[MANIFEST] = create_appx_manifest(params, files, releaseBuild) 181 files[MANIFEST] = create_appx_manifest(params, files, releaseBuild)
180 files[BLOCKMAP] = create_appx_blockmap(files) 182 files[BLOCKMAP] = create_appx_blockmap(files)
181 files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP]) 183 files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP])
182 184
183 files.zip(outfile, compression=zipfile.ZIP_STORED) 185 files.zip(outfile, compression=zipfile.ZIP_STORED)
OLDNEW
« no previous file with comments | « no previous file | releaseAutomation.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld