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

Delta Between Two Patch Sets: packagerChrome.py

Issue 5406295150559232: wrong icons parameter value in manifest.json for chrome buildtool fix. (Closed)
Left Patch Set: Created March 18, 2014, 4:03 p.m.
Right Patch Set: implement PIL in packagerChrome.py Created March 19, 2014, 2:50 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-2014 Eyeo GmbH 4 # Copyright (C) 2006-2014 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 for file in os.listdir(baseDir): 43 for file in os.listdir(baseDir):
44 if file.endswith('.js') or file.endswith('.html') or file.endswith('.xml'): 44 if file.endswith('.js') or file.endswith('.html') or file.endswith('.xml'):
45 result.add(file) 45 result.add(file)
46 return result 46 return result
47 47
48 def processFile(path, data, params): 48 def processFile(path, data, params):
49 # We don't change anything yet, this function currently only exists here so 49 # We don't change anything yet, this function currently only exists here so
50 # that it can be overridden if necessary. 50 # that it can be overridden if necessary.
51 return data 51 return data
52 52
53 def createManifest(params): 53 def createManifest(params, files):
54 template = getTemplate('manifest.json.tmpl') 54 template = getTemplate('manifest.json.tmpl')
55 templateData = dict(params) 55 templateData = dict(params)
56 56
57 baseDir = templateData['baseDir'] 57 baseDir = templateData['baseDir']
58 metadata = templateData['metadata'] 58 metadata = templateData['metadata']
59 59
60 if metadata.has_option('general', 'pageAction') and metadata.get('general', 'p ageAction') != '': 60 if metadata.has_option('general', 'pageAction') and metadata.get('general', 'p ageAction') != '':
61 if re.search(r'\s+', metadata.get('general', 'pageAction')): 61 if re.search(r'\s+', metadata.get('general', 'pageAction')):
62 icon, popup = re.split(r'\s+', metadata.get('general', 'pageAction'), 1) 62 icon, popup = re.split(r'\s+', metadata.get('general', 'pageAction'), 1)
63 else: 63 else:
64 icon, popup = (metadata.get('general', 'pageAction'), None) 64 icon, popup = (metadata.get('general', 'pageAction'), None)
65 templateData['pageAction'] = {'icon': icon, 'popup': popup} 65 templateData['pageAction'] = {'icon': icon, 'popup': popup}
66 66
67 if metadata.has_option('general', 'browserAction') and metadata.get('general', 'browserAction') != '': 67 if metadata.has_option('general', 'browserAction') and metadata.get('general', 'browserAction') != '':
68 if re.search(r'\s+', metadata.get('general', 'browserAction')): 68 if re.search(r'\s+', metadata.get('general', 'browserAction')):
69 icon, popup = re.split(r'\s+', metadata.get('general', 'browserAction'), 1 ) 69 icon, popup = re.split(r'\s+', metadata.get('general', 'browserAction'), 1 )
70 else: 70 else:
71 icon, popup = (metadata.get('general', 'browserAction'), None) 71 icon, popup = (metadata.get('general', 'browserAction'), None)
72 templateData['browserAction'] = {'icon': icon, 'popup': popup} 72 templateData['browserAction'] = {'icon': icon, 'popup': popup}
73 73
74 if metadata.has_option('general', 'icons'): 74 if metadata.has_option('general', 'icons'):
75 from PIL import Image
75 icons = {} 76 icons = {}
76 for icon in re.split('\s+', metadata.get('general', 'icons')): 77 for icon in re.split('\s+', metadata.get('general', 'icons')):
77 match = re.search("\d+(?=\.)", icon) 78 width, height = Image.open(StringIO(files[icon])).size
Wladimir Palant 2014/03/18 17:22:50 Determining icon size that way is even more a hack
saroyanm 2014/03/19 09:04:35 Good point, thanks for pointing. Updated.
78 if match: 79 if(width != height):
79 value = match.group() 80 print 'Warning: %s size is %ix%i, icon should be square' % (icon, width, height)
Wladimir Palant 2014/03/19 21:23:06 Errors and warnings should go to stderr: print
80 icons[value] = icon 81 icons[width] = icon
81 templateData['icons'] = icons 82 templateData['icons'] = icons
82 83
83 if metadata.has_option('general', 'permissions'): 84 if metadata.has_option('general', 'permissions'):
84 templateData['permissions'] = re.split(r'\s+', metadata.get('general', 'perm issions')) 85 templateData['permissions'] = re.split(r'\s+', metadata.get('general', 'perm issions'))
85 if params['experimentalAPI']: 86 if params['experimentalAPI']:
86 templateData['permissions'].append('experimental') 87 templateData['permissions'].append('experimental')
87 88
88 if metadata.has_option('general', 'backgroundScripts'): 89 if metadata.has_option('general', 'backgroundScripts'):
89 templateData['backgroundScripts'] = re.split(r'\s+', metadata.get('general', 'backgroundScripts')) 90 templateData['backgroundScripts'] = re.split(r'\s+', metadata.get('general', 'backgroundScripts'))
90 if params['devenv']: 91 if params['devenv']:
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 'baseDir': baseDir, 332 'baseDir': baseDir,
332 'releaseBuild': releaseBuild, 333 'releaseBuild': releaseBuild,
333 'version': version, 334 'version': version,
334 'experimentalAPI': experimentalAPI, 335 'experimentalAPI': experimentalAPI,
335 'devenv': devenv, 336 'devenv': devenv,
336 'metadata': metadata, 337 'metadata': metadata,
337 } 338 }
338 339
339 files = Files(getPackageFiles(params), getIgnoredFiles(params), 340 files = Files(getPackageFiles(params), getIgnoredFiles(params),
340 process=lambda path, data: processFile(path, data, params)) 341 process=lambda path, data: processFile(path, data, params))
341 files['manifest.json'] = createManifest(params) 342
342 if metadata.has_section('mapping'): 343 if metadata.has_section('mapping'):
343 files.readMappedFiles(metadata.items('mapping')) 344 files.readMappedFiles(metadata.items('mapping'))
344 files.read(baseDir) 345 files.read(baseDir)
345 346
346 if metadata.has_section('convert_js'): 347 if metadata.has_section('convert_js'):
347 convertJS(params, files) 348 convertJS(params, files)
348 349
349 if metadata.has_section('convert_img'): 350 if metadata.has_section('convert_img'):
350 from imageConversion import convertImages 351 from imageConversion import convertImages
351 convertImages(params, files) 352 convertImages(params, files)
352 353
353 if metadata.has_section('preprocess'): 354 if metadata.has_section('preprocess'):
354 files.preprocess( 355 files.preprocess(
355 [f for f, _ in metadata.items('preprocess')], 356 [f for f, _ in metadata.items('preprocess')],
356 {'needsExt': True} 357 {'needsExt': True}
357 ) 358 )
358 359
359 if metadata.has_section('import_locales'): 360 if metadata.has_section('import_locales'):
360 importGeckoLocales(params, files) 361 importGeckoLocales(params, files)
361 362
363 files['manifest.json'] = createManifest(params, files)
362 fixMissingTranslations(files) 364 fixMissingTranslations(files)
363 365
364 if devenv: 366 if devenv:
365 files['devenvPoller__.js'] = createPoller(params) 367 files['devenvPoller__.js'] = createPoller(params)
366 368
367 if (metadata.has_option('general', 'backgroundScripts') and 369 if (metadata.has_option('general', 'backgroundScripts') and
368 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip ts')) and 370 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip ts')) and
369 'lib/info.js' not in files): 371 'lib/info.js' not in files):
370 files['lib/info.js'] = createInfoModule(params) 372 files['lib/info.js'] = createInfoModule(params)
371 373
(...skipping 30 matching lines...) Expand all
402 def shutdown_server(server): 404 def shutdown_server(server):
403 time.sleep(10) 405 time.sleep(10)
404 server.shutdown() 406 server.shutdown()
405 thread.start_new_thread(shutdown_server, (server,)) 407 thread.start_new_thread(shutdown_server, (server,))
406 server.serve_forever() 408 server.serve_forever()
407 409
408 if connections[0] == 0: 410 if connections[0] == 0:
409 print 'Warning: No incoming connections, extension probably not active in th e browser yet' 411 print 'Warning: No incoming connections, extension probably not active in th e browser yet'
410 else: 412 else:
411 print 'Handled %i connection(s)' % connections[0] 413 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