Left: | ||
Right: |
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 = collections.defaultdict(list) | |
151 | |
150 for item in params['metadata'].items('convert_js'): | 152 for item in params['metadata'].items('convert_js'): |
151 filename, arg = re.search(r'^(.*?)(?:\[(.*)\])?$', item[0]).groups() | 153 filename, arg = re.search(r'^(.*?)(?:\[(.*)\])?$', item[0]).groups() |
152 if arg is None: | 154 if arg is None: |
153 output_files[filename] = (item[1].split(), item.source, []) | 155 output_files[filename] = (item[1].split(), item.source) |
154 else: | 156 else: |
155 output_files[filename][2].append('{}={}'.format(arg, item[1])) | 157 args[filename].append('{}={}'.format(arg, item[1])) |
Vasily Kuznetsov
2016/08/29 16:56:40
Perhaps we should issue a more user-friendly messa
Sebastian Noack
2016/08/30 12:40:31
Well, it's simpler to avoid that error than handli
Vasily Kuznetsov
2016/08/30 13:30:18
Indeed. Actually you can make the code even cleane
Sebastian Noack
2016/08/30 14:06:50
Yeah, that is even better. Done.
| |
156 | 158 |
157 for filename, (input_files, origin, args) in output_files.iteritems(): | 159 for filename, (input_files, origin) in output_files.iteritems(): |
158 if '/' in filename and not files.isIncluded(filename): | 160 if '/' in filename and not files.isIncluded(filename): |
159 continue | 161 continue |
160 | 162 |
161 base_dir = os.path.dirname(origin) | 163 base_dir = os.path.dirname(origin) |
162 jshydra_args = ['--arg', ' '.join(args)] | 164 jshydra_args = ['--arg', ' '.join(args[filename])] |
163 | 165 |
164 for input_filename in input_files: | 166 for input_filename in input_files: |
165 jshydra_args.append(os.path.join(base_dir, input_filename)) | 167 jshydra_args.append(os.path.join(base_dir, input_filename)) |
166 files.pop(input_filename, None) | 168 files.pop(input_filename, None) |
167 | 169 |
168 files[filename] = rewrite_js(jshydra_args) | 170 files[filename] = rewrite_js(jshydra_args) |
169 | 171 |
170 | 172 |
171 def toJson(data): | 173 def toJson(data): |
172 return json.dumps( | 174 return json.dumps( |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmp l', | 384 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmp l', |
383 ('general', 'testScripts')) | 385 ('general', 'testScripts')) |
384 | 386 |
385 zipdata = files.zipToString() | 387 zipdata = files.zipToString() |
386 signature = None | 388 signature = None |
387 pubkey = None | 389 pubkey = None |
388 if keyFile != None: | 390 if keyFile != None: |
389 signature = signBinary(zipdata, keyFile) | 391 signature = signBinary(zipdata, keyFile) |
390 pubkey = getPublicKey(keyFile) | 392 pubkey = getPublicKey(keyFile) |
391 writePackage(outFile, pubkey, signature, zipdata) | 393 writePackage(outFile, pubkey, signature, zipdata) |
LEFT | RIGHT |