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

Delta Between Two Patch Sets: packagerChrome.py

Issue 29562599: Issue 5751 - Removing legacy gecko support (Closed)
Left Patch Set: Tidy tox.ini, further simplify import_locales Created Oct. 6, 2017, 9:01 a.m.
Right Patch Set: Rebase against current master ( 489:293593da6033 ) Created Oct. 10, 2017, 9:25 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
« build.py ('K') | « packager.py ('k') | packagerGecko.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 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 data, ensure_ascii=False, sort_keys=True, 189 data, ensure_ascii=False, sort_keys=True,
190 indent=2, separators=(',', ': ') 190 indent=2, separators=(',', ': ')
191 ).encode('utf-8') + '\n' 191 ).encode('utf-8') + '\n'
192 192
193 193
194 def import_locales(params, files): 194 def import_locales(params, files):
195 for item in params['metadata'].items('import_locales'): 195 for item in params['metadata'].items('import_locales'):
196 filename, keys = item 196 filename, keys = item
197 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source), 197 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source),
198 *filename.split('/'))): 198 *filename.split('/'))):
199 locale = sourceFile.split(os.path.sep)[-2].replace('-', '_') 199 locale = sourceFile.split(os.path.sep)[-2]
Sebastian Noack 2017/10/06 19:13:28 As pointed out on the review introducing this code
tlucas 2017/10/09 23:18:07 Done.
200 targetFile = os.path.join('_locales', locale, 'messages.json') 200 targetFile = os.path.join('_locales', locale, 'messages.json')
201 data = json.loads(files.get(targetFile, '{}').decode('utf-8')) 201 data = json.loads(files.get(targetFile, '{}').decode('utf-8'))
202 202
203 try: 203 try:
204 with io.open(sourceFile, 'r', encoding='utf-8') as handle: 204 with io.open(sourceFile, 'r', encoding='utf-8') as handle:
205 sourceData = json.load(handle) 205 sourceData = json.load(handle)
206 206
207 # Resolve wildcard imports 207 # Resolve wildcard imports
208 if keys == '*' or keys == '=*': 208 if keys == '*':
209 importList = sourceData.keys() 209 importList = sourceData.keys()
210 importList = filter(lambda k: not k.startswith('_'), importL ist) 210 importList = filter(lambda k: not k.startswith('_'), importL ist)
211 if keys == '=*':
212 importList = map(lambda k: '=' + k, importList)
213 keys = ' '.join(importList) 211 keys = ' '.join(importList)
214 212
215 for stringID in keys.split(): 213 for stringID in keys.split():
216 noMangling = False
217 if stringID.startswith('='):
218 stringID = stringID[1:]
219
220 if stringID in sourceData: 214 if stringID in sourceData:
221 key = re.sub(r'\W', '_', stringID) 215 if stringID in data:
Sebastian Noack 2017/10/06 19:13:29 This should no longer be necessary either, as we w
tlucas 2017/10/09 23:18:07 A quick test verified your assumption, this line h
222 if key in data: 216 print ('Warning: locale string {} defined multiple'
223 print 'Warning: locale string %s defined multiple ti mes' % key 217 ' times').format(stringID)
224 218
225 data[key] = sourceData[stringID] 219 data[stringID] = sourceData[stringID]
226 except Exception as e: 220 except Exception as e:
227 print 'Warning: error importing locale data from %s: %s' % (sour ceFile, e) 221 print 'Warning: error importing locale data from %s: %s' % (sour ceFile, e)
228 222
229 files[targetFile] = toJson(data) 223 files[targetFile] = toJson(data)
230 224
231 225
232 def truncate(text, length_limit): 226 def truncate(text, length_limit):
233 if len(text) <= length_limit: 227 if len(text) <= length_limit:
234 return text 228 return text
235 return text[:length_limit - 1].rstrip() + u'\u2026' 229 return text[:length_limit - 1].rstrip() + u'\u2026'
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 params, 'testIndex.html.tmpl', ('general', 'testScripts') 359 params, 'testIndex.html.tmpl', ('general', 'testScripts')
366 ) 360 )
367 361
368 zipdata = files.zipToString() 362 zipdata = files.zipToString()
369 signature = None 363 signature = None
370 pubkey = None 364 pubkey = None
371 if keyFile != None: 365 if keyFile != None:
372 signature = signBinary(zipdata, keyFile) 366 signature = signBinary(zipdata, keyFile)
373 pubkey = getPublicKey(keyFile) 367 pubkey = getPublicKey(keyFile)
374 writePackage(outFile, pubkey, signature, zipdata) 368 writePackage(outFile, pubkey, signature, zipdata)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld