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

Delta Between Two Patch Sets: packagerChrome.py

Issue 5702288324689920: Make sure that translations used in manifest.json exist in all languages (Closed)
Left Patch Set: Created March 13, 2014, 3:12 p.m.
Right Patch Set: Fixed malformed indentation Created March 13, 2014, 3:51 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 | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus build tools, 3 # This file is part of the Adblock Plus build tools,
4 # Copyright (C) 2006-2013 Eyeo GmbH 4 # Copyright (C) 2006-2013 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 for chromeLocale, operaLocale in operaMapping.iteritems(): 279 for chromeLocale, operaLocale in operaMapping.iteritems():
280 chromeFile = '_locales/%s/messages.json' % chromeLocale 280 chromeFile = '_locales/%s/messages.json' % chromeLocale
281 operaFile = '_locales/%s/messages.json' % operaLocale if operaLocale != No ne else None 281 operaFile = '_locales/%s/messages.json' % operaLocale if operaLocale != No ne else None
282 if chromeFile in files: 282 if chromeFile in files:
283 if operaFile != None: 283 if operaFile != None:
284 files[operaFile] = files[chromeFile] 284 files[operaFile] = files[chromeFile]
285 del files[chromeFile] 285 del files[chromeFile]
286 286
287 def fixMissingTranslations(files): 287 def fixMissingTranslations(files):
288 # Chrome requires messages used in manifest.json to be given in all languages 288 # Chrome requires messages used in manifest.json to be given in all languages
289 defaults = [] 289 defaults = {}
290 for name, info in json.loads(files['_locales/%s/messages.json' % defaultLocale ]).iteritems(): 290 data = json.loads(files['_locales/%s/messages.json' % defaultLocale])
291 if '__MSG_%s__' % name in files['manifest.json']: 291 for match in re.finditer(r'__MSG_(\S+)__', files['manifest.json']):
292 defaults.append((name, info)) 292 name = match.group(1)
Wladimir Palant 2014/03/13 15:21:45 This seems backwards, shouldn't we search for __MS
Sebastian Noack 2014/03/13 15:44:33 Done.
293 defaults[name] = data[name]
293 294
294 for filename in files: 295 for filename in files:
295 if not filename.startswith('_locales/') or not filename.endswith('/messages. json'): 296 if not filename.startswith('_locales/') or not filename.endswith('/messages. json'):
296 continue 297 continue
297 298
298 data = json.loads(files[filename]) 299 data = json.loads(files[filename])
299 for name, info in defaults: 300 for name, info in defaults.iteritems():
300 data.setdefault(name, info) 301 data.setdefault(name, info)
301 302
302 files[filename] = toJson(data) 303 files[filename] = toJson(data)
303 304
304 def signBinary(zipdata, keyFile): 305 def signBinary(zipdata, keyFile):
305 import M2Crypto 306 import M2Crypto
306 if not os.path.exists(keyFile): 307 if not os.path.exists(keyFile):
307 M2Crypto.RSA.gen_key(1024, 65537, callback=lambda x: None).save_key(keyFile, cipher=None) 308 M2Crypto.RSA.gen_key(1024, 65537, callback=lambda x: None).save_key(keyFile, cipher=None)
308 key = M2Crypto.EVP.load_key(keyFile) 309 key = M2Crypto.EVP.load_key(keyFile)
309 key.sign_init() 310 key.sign_init()
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 def shutdown_server(server): 409 def shutdown_server(server):
409 time.sleep(10) 410 time.sleep(10)
410 server.shutdown() 411 server.shutdown()
411 thread.start_new_thread(shutdown_server, (server,)) 412 thread.start_new_thread(shutdown_server, (server,))
412 server.serve_forever() 413 server.serve_forever()
413 414
414 if connections[0] == 0: 415 if connections[0] == 0:
415 print 'Warning: No incoming connections, extension probably not active in th e browser yet' 416 print 'Warning: No incoming connections, extension probably not active in th e browser yet'
416 else: 417 else:
417 print 'Handled %i connection(s)' % connections[0] 418 print 'Handled %i connection(s)' % connections[0]
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld