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: Rebasing against #5763 @ Patch Set 7 Created Oct. 6, 2017, 8:54 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 parts = sourceFile.split(os.path.sep) 199 locale = sourceFile.split(os.path.sep)[-2]
200 locale = parts[-2].replace('-', '_')
201 targetFile = os.path.join('_locales', locale, 'messages.json') 200 targetFile = os.path.join('_locales', locale, 'messages.json')
202 data = json.loads(files.get(targetFile, '{}').decode('utf-8')) 201 data = json.loads(files.get(targetFile, '{}').decode('utf-8'))
203 202
204 try: 203 try:
205 with io.open(sourceFile, 'r', encoding='utf-8') as handle: 204 with io.open(sourceFile, 'r', encoding='utf-8') as handle:
206 sourceData = json.load(handle) 205 sourceData = json.load(handle)
207 206
208 # Resolve wildcard imports 207 # Resolve wildcard imports
209 if keys == '*' or keys == '=*': 208 if keys == '*':
210 importList = sourceData.keys() 209 importList = sourceData.keys()
211 importList = filter(lambda k: not k.startswith('_'), importL ist) 210 importList = filter(lambda k: not k.startswith('_'), importL ist)
212 if keys == '=*':
213 importList = map(lambda k: '=' + k, importList)
214 keys = ' '.join(importList) 211 keys = ' '.join(importList)
215 212
216 for stringID in keys.split(): 213 for stringID in keys.split():
217 noMangling = False
218 if stringID.startswith('='):
219 stringID = stringID[1:]
220 noMangling = True
221
222 if stringID in sourceData: 214 if stringID in sourceData:
223 if noMangling: 215 if stringID in data:
224 key = re.sub(r'\W', '_', stringID) 216 print ('Warning: locale string {} defined multiple'
225 else: 217 ' times').format(stringID)
226 key = re.sub(r'\..*', '', parts[-1]) + '_' + re.sub( r'\W', '_', stringID) 218
227 if key in data: 219 data[stringID] = sourceData[stringID]
228 print 'Warning: locale string %s defined multiple ti mes' % key
229
230 data[key] = sourceData[stringID]
231 except Exception as e: 220 except Exception as e:
232 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)
233 222
234 files[targetFile] = toJson(data) 223 files[targetFile] = toJson(data)
235 224
236 225
237 def truncate(text, length_limit): 226 def truncate(text, length_limit):
238 if len(text) <= length_limit: 227 if len(text) <= length_limit:
239 return text 228 return text
240 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
370 params, 'testIndex.html.tmpl', ('general', 'testScripts') 359 params, 'testIndex.html.tmpl', ('general', 'testScripts')
371 ) 360 )
372 361
373 zipdata = files.zipToString() 362 zipdata = files.zipToString()
374 signature = None 363 signature = None
375 pubkey = None 364 pubkey = None
376 if keyFile != None: 365 if keyFile != None:
377 signature = signBinary(zipdata, keyFile) 366 signature = signBinary(zipdata, keyFile)
378 pubkey = getPublicKey(keyFile) 367 pubkey = getPublicKey(keyFile)
379 writePackage(outFile, pubkey, signature, zipdata) 368 writePackage(outFile, pubkey, signature, zipdata)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld