OLD | NEW |
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 Loading... |
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 scripts=params['metadata'].get(*script_option).split() |
| 64 ).encode('utf-8') |
| 65 |
60 def createManifest(params, files): | 66 def createManifest(params, files): |
61 template = getTemplate('manifest.json.tmpl') | 67 template = getTemplate('manifest.json.tmpl') |
62 templateData = dict(params) | 68 templateData = dict(params) |
63 | 69 |
64 baseDir = templateData['baseDir'] | 70 baseDir = templateData['baseDir'] |
65 metadata = templateData['metadata'] | 71 metadata = templateData['metadata'] |
66 | 72 |
67 for opt in ('browserAction', 'pageAction'): | 73 for opt in ('browserAction', 'pageAction'): |
68 if not metadata.has_option('general', opt): | 74 if not metadata.has_option('general', opt): |
69 continue | 75 continue |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 import buildtools | 356 import buildtools |
351 import random | 357 import random |
352 files.read(os.path.join(buildtools.__path__[0], 'chromeDevenvPoller__.js'),
relpath='devenvPoller__.js') | 358 files.read(os.path.join(buildtools.__path__[0], 'chromeDevenvPoller__.js'),
relpath='devenvPoller__.js') |
353 files['devenvVersion__'] = str(random.random()) | 359 files['devenvVersion__'] = str(random.random()) |
354 | 360 |
355 if (metadata.has_option('general', 'backgroundScripts') and | 361 if (metadata.has_option('general', 'backgroundScripts') and |
356 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip
ts')) and | 362 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip
ts')) and |
357 'lib/info.js' not in files): | 363 'lib/info.js' not in files): |
358 files['lib/info.js'] = createInfoModule(params) | 364 files['lib/info.js'] = createInfoModule(params) |
359 | 365 |
| 366 if metadata.has_option('general', 'testScripts'): |
| 367 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmpl', |
| 368 ('general', 'testScripts')) |
| 369 |
360 zipdata = files.zipToString() | 370 zipdata = files.zipToString() |
361 signature = None | 371 signature = None |
362 pubkey = None | 372 pubkey = None |
363 if keyFile != None: | 373 if keyFile != None: |
364 signature = signBinary(zipdata, keyFile) | 374 signature = signBinary(zipdata, keyFile) |
365 pubkey = getPublicKey(keyFile) | 375 pubkey = getPublicKey(keyFile) |
366 writePackage(outFile, pubkey, signature, zipdata) | 376 writePackage(outFile, pubkey, signature, zipdata) |
OLD | NEW |