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

Side by Side Diff: packagerChrome.py

Issue 29326188: Issue 3039 - Generate qunit/index.html based on metadata (Closed)
Patch Set: Avoid hardcoding "Adblock Plus", instead use basename Created Sept. 9, 2015, 4:28 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « background.html.tmpl ('k') | packagerSafari.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This Source Code Form is subject to the terms of the Mozilla Public 3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 6
7 import sys 7 import sys
8 import os 8 import os
9 import re 9 import re
10 import json 10 import json
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 except ImportError: 50 except ImportError:
51 import Image 51 import Image
52 icons = {} 52 icons = {}
53 for filename in filenames: 53 for filename in filenames:
54 width, height = Image.open(StringIO(files[filename])).size 54 width, height = Image.open(StringIO(files[filename])).size
55 if(width != height): 55 if(width != height):
56 print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be square' % ( filename, width, height) 56 print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be square' % ( filename, width, height)
57 icons[width] = filename 57 icons[width] = filename
58 return icons 58 return icons
59 59
60 def createScriptPage(params, template_name, script_option):
61 template = getTemplate(template_name, autoEscape=True)
62 return template.render(
63 basename=params['metadata'].get('general', 'basename'),
64 scripts=params['metadata'].get(*script_option).split()
65 ).encode('utf-8')
66
60 def createManifest(params, files): 67 def createManifest(params, files):
61 template = getTemplate('manifest.json.tmpl') 68 template = getTemplate('manifest.json.tmpl')
62 templateData = dict(params) 69 templateData = dict(params)
63 70
64 baseDir = templateData['baseDir'] 71 baseDir = templateData['baseDir']
65 metadata = templateData['metadata'] 72 metadata = templateData['metadata']
66 73
67 for opt in ('browserAction', 'pageAction'): 74 for opt in ('browserAction', 'pageAction'):
68 if not metadata.has_option('general', opt): 75 if not metadata.has_option('general', opt):
69 continue 76 continue
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 import buildtools 357 import buildtools
351 import random 358 import random
352 files.read(os.path.join(buildtools.__path__[0], 'chromeDevenvPoller__.js'), relpath='devenvPoller__.js') 359 files.read(os.path.join(buildtools.__path__[0], 'chromeDevenvPoller__.js'), relpath='devenvPoller__.js')
353 files['devenvVersion__'] = str(random.random()) 360 files['devenvVersion__'] = str(random.random())
354 361
355 if (metadata.has_option('general', 'backgroundScripts') and 362 if (metadata.has_option('general', 'backgroundScripts') and
356 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip ts')) and 363 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip ts')) and
357 'lib/info.js' not in files): 364 'lib/info.js' not in files):
358 files['lib/info.js'] = createInfoModule(params) 365 files['lib/info.js'] = createInfoModule(params)
359 366
367 if metadata.has_option('general', 'testScripts'):
368 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmpl',
369 ('general', 'testScripts'))
370
360 zipdata = files.zipToString() 371 zipdata = files.zipToString()
361 signature = None 372 signature = None
362 pubkey = None 373 pubkey = None
363 if keyFile != None: 374 if keyFile != None:
364 signature = signBinary(zipdata, keyFile) 375 signature = signBinary(zipdata, keyFile)
365 pubkey = getPublicKey(keyFile) 376 pubkey = getPublicKey(keyFile)
366 writePackage(outFile, pubkey, signature, zipdata) 377 writePackage(outFile, pubkey, signature, zipdata)
OLDNEW
« no previous file with comments | « background.html.tmpl ('k') | packagerSafari.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld