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: Created Oct. 28, 2016, 10:37 a.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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 # original content would be lost. 107 # original content would be lost.
108 names = sorted(files.keys(), key=len, reverse=True) 108 names = sorted(files.keys(), key=len, reverse=True)
109 for filename in names: 109 for filename in names:
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 '.otf': 'application/octet-stream',
Sebastian Noack 2016/10/28 12:43:51 Why not using 'application/font-sfnt' or 'applicat
Vasily Kuznetsov 2016/11/30 15:11:45 'application/octet-stream' is what Microsoft and F
117 BLOCKMAP: 'application/vnd.ms-appx.blockmap+xml', 118 BLOCKMAP: 'application/vnd.ms-appx.blockmap+xml',
118 MANIFEST: 'application/vnd.ms-appx.manifest+xml' 119 MANIFEST: 'application/vnd.ms-appx.manifest+xml'
119 } 120 }
120 for filename in filenames: 121 for filename in filenames:
121 ext = os.path.splitext(filename)[1] 122 ext = os.path.splitext(filename)[1]
122 if ext: 123 if ext and ext not in params['defaults']:
Sebastian Noack 2016/10/28 12:43:51 Rather than adding a special case here, note that
Vasily Kuznetsov 2016/11/30 15:11:45 You're right, this is better. Done.
123 content_type = mimetypes.guess_type(filename, strict=False)[0] 124 content_type = mimetypes.guess_type(filename, strict=False)[0]
125 if ext in overrides:
126 content_type = overrides[ext]
124 if content_type is not None: 127 if content_type is not None:
125 params['defaults'][ext[1:]] = content_type 128 params['defaults'][ext[1:]] = content_type
126 if filename in overrides: 129 if filename in overrides:
127 params['overrides']['/' + filename] = overrides[filename] 130 params['overrides']['/' + filename] = overrides[filename]
128 content_types_template = _get_template_for(CONTENT_TYPES) 131 content_types_template = _get_template_for(CONTENT_TYPES)
129 return content_types_template.render(params).encode('utf-8') 132 return content_types_template.render(params).encode('utf-8')
130 133
131 134
132 def createBuild(baseDir, type='edge', outFile=None, # noqa: preserve API. 135 def createBuild(baseDir, type='edge', outFile=None, # noqa: preserve API.
133 buildNum=None, releaseBuild=False, keyFile=None, 136 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'): 177 if metadata.has_section('appx_assets'):
175 for name, path in metadata.items('appx_assets'): 178 for name, path in metadata.items('appx_assets'):
176 path = os.path.join(baseDir, path) 179 path = os.path.join(baseDir, path)
177 files.read(path, '{}/{}'.format(ASSETS_DIR, name)) 180 files.read(path, '{}/{}'.format(ASSETS_DIR, name))
178 181
179 files[MANIFEST] = create_appx_manifest(params, files, releaseBuild) 182 files[MANIFEST] = create_appx_manifest(params, files, releaseBuild)
180 files[BLOCKMAP] = create_appx_blockmap(files) 183 files[BLOCKMAP] = create_appx_blockmap(files)
181 files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP]) 184 files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP])
182 185
183 files.zip(outfile, compression=zipfile.ZIP_STORED) 186 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