Left: | ||
Right: |
OLD | NEW |
---|---|
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 glob | 6 import glob |
7 import io | 7 import io |
8 import json | 8 import json |
9 import os | 9 import os |
10 import re | 10 import re |
11 import struct | 11 import struct |
12 import subprocess | 12 import subprocess |
13 import sys | 13 import sys |
14 import random | 14 import random |
15 import posixpath | |
15 | 16 |
16 from packager import (readMetadata, getDefaultFileName, getBuildVersion, | 17 from packager import (readMetadata, getDefaultFileName, getBuildVersion, |
17 getTemplate, Files) | 18 getTemplate, Files) |
18 | 19 |
19 defaultLocale = 'en_US' | 20 defaultLocale = 'en_US' |
20 | 21 |
21 | 22 |
22 def getIgnoredFiles(params): | 23 def getIgnoredFiles(params): |
23 return {'store.description'} | 24 return {'store.description'} |
24 | 25 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 files[bundle] = output['files'][bundle].encode('utf-8') | 208 files[bundle] = output['files'][bundle].encode('utf-8') |
208 | 209 |
209 | 210 |
210 def import_locales(params, files): | 211 def import_locales(params, files): |
211 for item in params['metadata'].items('import_locales'): | 212 for item in params['metadata'].items('import_locales'): |
212 filename = item[0] | 213 filename = item[0] |
213 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source), | 214 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source), |
214 *filename.split('/'))): | 215 *filename.split('/'))): |
215 keys = item[1] | 216 keys = item[1] |
216 locale = sourceFile.split(os.path.sep)[-2] | 217 locale = sourceFile.split(os.path.sep)[-2] |
217 targetFile = os.path.join('_locales', locale, 'messages.json') | 218 targetFile = posixpath.join('_locales', locale, 'messages.json') |
Oleksandr
2017/10/26 09:16:02
A more generic approach would be to not rely on an
Wladimir Palant
2017/10/26 09:22:13
ZIP archives (which is what we are talking about h
| |
218 data = json.loads(files.get(targetFile, '{}').decode('utf-8')) | 219 data = json.loads(files.get(targetFile, '{}').decode('utf-8')) |
219 | 220 |
220 try: | 221 try: |
221 with io.open(sourceFile, 'r', encoding='utf-8') as handle: | 222 with io.open(sourceFile, 'r', encoding='utf-8') as handle: |
222 sourceData = json.load(handle) | 223 sourceData = json.load(handle) |
223 | 224 |
224 # Resolve wildcard imports | 225 # Resolve wildcard imports |
225 if keys == '*': | 226 if keys == '*': |
226 importList = sourceData.keys() | 227 importList = sourceData.keys() |
227 importList = filter(lambda k: not k.startswith('_'), importL ist) | 228 importList = filter(lambda k: not k.startswith('_'), importL ist) |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 if devenv: | 382 if devenv: |
382 add_devenv_requirements(files, metadata, params) | 383 add_devenv_requirements(files, metadata, params) |
383 | 384 |
384 zipdata = files.zipToString() | 385 zipdata = files.zipToString() |
385 signature = None | 386 signature = None |
386 pubkey = None | 387 pubkey = None |
387 if keyFile != None: | 388 if keyFile != None: |
388 signature = signBinary(zipdata, keyFile) | 389 signature = signBinary(zipdata, keyFile) |
389 pubkey = getPublicKey(keyFile) | 390 pubkey = getPublicKey(keyFile) |
390 writePackage(outFile, pubkey, signature, zipdata) | 391 writePackage(outFile, pubkey, signature, zipdata) |
OLD | NEW |