LEFT | RIGHT |
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 |
11 import struct | 11 import struct |
12 import sys | 12 import sys |
13 from collections import OrderedDict | 13 import collections |
14 | 14 |
15 import packager | 15 import packager |
16 from packager import readMetadata, getMetadataPath, getDefaultFileName, getBuild
Version, getTemplate, Files | 16 from packager import readMetadata, getMetadataPath, getDefaultFileName, getBuild
Version, getTemplate, Files |
17 | 17 |
18 defaultLocale = 'en_US' | 18 defaultLocale = 'en_US' |
19 | 19 |
20 | 20 |
21 def getIgnoredFiles(params): | 21 def getIgnoredFiles(params): |
22 return {'store.description'} | 22 return {'store.description'} |
23 | 23 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 139 |
140 | 140 |
141 def createInfoModule(params): | 141 def createInfoModule(params): |
142 template = getTemplate('chromeInfo.js.tmpl') | 142 template = getTemplate('chromeInfo.js.tmpl') |
143 return template.render(params).encode('utf-8') | 143 return template.render(params).encode('utf-8') |
144 | 144 |
145 | 145 |
146 def convertJS(params, files): | 146 def convertJS(params, files): |
147 from jshydra.abp_rewrite import rewrite_js | 147 from jshydra.abp_rewrite import rewrite_js |
148 | 148 |
149 output_files = OrderedDict() | 149 output_files = collections.OrderedDict() |
150 args = {} | 150 args = collections.defaultdict(list) |
| 151 |
151 for item in params['metadata'].items('convert_js'): | 152 for item in params['metadata'].items('convert_js'): |
152 filename, arg = re.search(r'^(.*?)(?:\[(.*)\])?$', item[0]).groups() | 153 filename, arg = re.search(r'^(.*?)(?:\[(.*)\])?$', item[0]).groups() |
153 if arg is None: | 154 if arg is None: |
154 output_files[filename] = (item[1].split(), item.source) | 155 output_files[filename] = (item[1].split(), item.source) |
155 else: | 156 else: |
156 args.setdefault(filename, []).append('{}={}'.format(arg, item[1])) | 157 args[filename].append('{}={}'.format(arg, item[1])) |
157 | 158 |
158 for filename, (input_files, origin) in output_files.iteritems(): | 159 for filename, (input_files, origin) in output_files.iteritems(): |
159 if '/' in filename and not files.isIncluded(filename): | 160 if '/' in filename and not files.isIncluded(filename): |
160 continue | 161 continue |
161 | 162 |
162 base_dir = os.path.dirname(origin) | 163 base_dir = os.path.dirname(origin) |
163 jshydra_args = ['--arg', ' '.join(args.get(filename, []))] | 164 jshydra_args = ['--arg', ' '.join(args[filename])] |
164 | 165 |
165 for input_filename in input_files: | 166 for input_filename in input_files: |
166 jshydra_args.append(os.path.join(base_dir, input_filename)) | 167 jshydra_args.append(os.path.join(base_dir, input_filename)) |
167 files.pop(input_filename, None) | 168 files.pop(input_filename, None) |
168 | 169 |
169 files[filename] = rewrite_js(jshydra_args) | 170 files[filename] = rewrite_js(jshydra_args) |
170 | 171 |
171 | 172 |
172 def toJson(data): | 173 def toJson(data): |
173 return json.dumps( | 174 return json.dumps( |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmp
l', | 384 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmp
l', |
384 ('general', 'testScripts')) | 385 ('general', 'testScripts')) |
385 | 386 |
386 zipdata = files.zipToString() | 387 zipdata = files.zipToString() |
387 signature = None | 388 signature = None |
388 pubkey = None | 389 pubkey = None |
389 if keyFile != None: | 390 if keyFile != None: |
390 signature = signBinary(zipdata, keyFile) | 391 signature = signBinary(zipdata, keyFile) |
391 pubkey = getPublicKey(keyFile) | 392 pubkey = getPublicKey(keyFile) |
392 writePackage(outFile, pubkey, signature, zipdata) | 393 writePackage(outFile, pubkey, signature, zipdata) |
LEFT | RIGHT |