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

Delta Between Two Patch Sets: packagerChrome.py

Issue 29561557: Issue 5763 - Target languages supported by Firefox (Closed)
Left Patch Set: Fixed import_locales() Created Oct. 5, 2017, 6:25 p.m.
Right Patch Set: Fixed undefined variable, put URLS in globals, removed redundand flake8 ignores Created Oct. 5, 2017, 8:54 p.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 | « localeTools.py ('k') | tox.ini » ('j') | tox.ini » ('J')
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 io 6 import io
7 import json 7 import json
8 import os 8 import os
9 import re 9 import re
10 from StringIO import StringIO 10 from StringIO import StringIO
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 value = value[0:index] + value[index + 1:] 211 value = value[0:index] + value[index + 1:]
212 212
213 data[key] = {'message': value} 213 data[key] = {'message': value}
214 214
215 215
216 def import_locales(params, files): 216 def import_locales(params, files):
217 for item in params['metadata'].items('import_locales'): 217 for item in params['metadata'].items('import_locales'):
218 filename, keys = item 218 filename, keys = item
219 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source), 219 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source),
220 *filename.split('/'))): 220 *filename.split('/'))):
221 locale = sourceFile.split(os.path.sep)[-2].replace('-', '_') 221 parts = sourceFile.split(os.path.sep)
Sebastian Noack 2017/10/05 19:01:43 Replacing dashes with underscore here is only nece
Sebastian Noack 2017/10/05 20:58:38 I just noticed that the variable "parts" is used b
tlucas 2017/10/06 08:53:53 Acknowledged.
222 locale = parts[-2].replace('-', '_')
222 targetFile = os.path.join('_locales', locale, 'messages.json') 223 targetFile = os.path.join('_locales', locale, 'messages.json')
223 data = json.loads(files.get(targetFile, '{}').decode('utf-8')) 224 data = json.loads(files.get(targetFile, '{}').decode('utf-8'))
224 225
225 try: 226 try:
226 # The WebExtensions (.json) and Gecko format provide 227 # The WebExtensions (.json) and Gecko format provide
227 # translations differently and/or provide additional 228 # translations differently and/or provide additional
228 # information like e.g. "placeholders". We want to adhere to 229 # information like e.g. "placeholders". We want to adhere to
229 # that and preserve the addtional info. 230 # that and preserve the addtional info.
230 if sourceFile.endswith('.json'): 231 if sourceFile.endswith('.json'):
231 with io.open(sourceFile, 'r', encoding='utf-8') as handle: 232 with io.open(sourceFile, 'r', encoding='utf-8') as handle:
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 params, 'testIndex.html.tmpl', ('general', 'testScripts') 402 params, 'testIndex.html.tmpl', ('general', 'testScripts')
402 ) 403 )
403 404
404 zipdata = files.zipToString() 405 zipdata = files.zipToString()
405 signature = None 406 signature = None
406 pubkey = None 407 pubkey = None
407 if keyFile != None: 408 if keyFile != None:
408 signature = signBinary(zipdata, keyFile) 409 signature = signBinary(zipdata, keyFile)
409 pubkey = getPublicKey(keyFile) 410 pubkey = getPublicKey(keyFile)
410 writePackage(outFile, pubkey, signature, zipdata) 411 writePackage(outFile, pubkey, signature, zipdata)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld