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

Delta Between Two Patch Sets: packagerChrome.py

Issue 29574582: Issue 5535 - Replace our module system with webpack (Closed)
Left Patch Set: Created Oct. 12, 2017, 11:53 a.m.
Right Patch Set: Addressed nit Created Oct. 13, 2017, 7:24 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « package.json ('k') | packagerEdge.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 errno 5 import errno
6 import glob 6 import glob
7 import io 7 import io
8 import json 8 import json
9 import os 9 import os
10 import re 10 import re
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 'bundle_name': bundle_file, 187 'bundle_name': bundle_file,
188 'entry_points': entry_files, 188 'entry_points': entry_files,
189 }) 189 })
190 190
191 cmd = ['node', os.path.join(os.path.dirname(__file__), 'webpack_runner.js')] 191 cmd = ['node', os.path.join(os.path.dirname(__file__), 'webpack_runner.js')]
192 process = subprocess.Popen(cmd, stdout=subprocess.PIPE, 192 process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
193 stdin=subprocess.PIPE) 193 stdin=subprocess.PIPE)
194 output = process.communicate(input=toJson(configuration))[0] 194 output = process.communicate(input=toJson(configuration))[0]
195 if process.returncode != 0: 195 if process.returncode != 0:
196 raise subprocess.CalledProcessError(process.returncode, cmd=cmd) 196 raise subprocess.CalledProcessError(process.returncode, cmd=cmd)
197 197 output = json.loads(output)
198 bundles = json.loads(output) 198
199 for bundle in bundles: 199 # Clear the mapping for any files included in a bundle, to avoid them being
200 files[bundle] = bundles[bundle].encode('utf-8') 200 # duplicated in the build.
201 for to_ignore in output['included']:
202 files.pop(to_ignore, None)
203
204 for bundle in output['files']:
205 files[bundle] = output['files'][bundle].encode('utf-8')
201 206
202 207
203 def import_locales(params, files): 208 def import_locales(params, files):
204 for item in params['metadata'].items('import_locales'): 209 for item in params['metadata'].items('import_locales'):
205 filename, keys = item 210 filename, keys = item
206 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source), 211 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source),
207 *filename.split('/'))): 212 *filename.split('/'))):
208 locale = sourceFile.split(os.path.sep)[-2] 213 locale = sourceFile.split(os.path.sep)[-2]
209 targetFile = os.path.join('_locales', locale, 'messages.json') 214 targetFile = os.path.join('_locales', locale, 'messages.json')
210 data = json.loads(files.get(targetFile, '{}').decode('utf-8')) 215 data = json.loads(files.get(targetFile, '{}').decode('utf-8'))
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 params, 'testIndex.html.tmpl', ('general', 'testScripts') 373 params, 'testIndex.html.tmpl', ('general', 'testScripts')
369 ) 374 )
370 375
371 zipdata = files.zipToString() 376 zipdata = files.zipToString()
372 signature = None 377 signature = None
373 pubkey = None 378 pubkey = None
374 if keyFile != None: 379 if keyFile != None:
375 signature = signBinary(zipdata, keyFile) 380 signature = signBinary(zipdata, keyFile)
376 pubkey = getPublicKey(keyFile) 381 pubkey = getPublicKey(keyFile)
377 writePackage(outFile, pubkey, signature, zipdata) 382 writePackage(outFile, pubkey, signature, zipdata)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld