| 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 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 # duplicated in the build. | 202 # duplicated in the build. |
| 203 for to_ignore in output['included']: | 203 for to_ignore in output['included']: |
| 204 files.pop(to_ignore, None) | 204 files.pop(to_ignore, None) |
| 205 | 205 |
| 206 for bundle in output['files']: | 206 for bundle in output['files']: |
| 207 files[bundle] = output['files'][bundle].encode('utf-8') | 207 files[bundle] = output['files'][bundle].encode('utf-8') |
| 208 | 208 |
| 209 | 209 |
| 210 def import_locales(params, files): | 210 def import_locales(params, files): |
| 211 for item in params['metadata'].items('import_locales'): | 211 for item in params['metadata'].items('import_locales'): |
| 212 filename, keys = item | 212 filename = item[0] |
|
Sebastian Noack
2017/10/25 15:08:33
Nit: This temporary variable isnt necessary.
Wladimir Palant
2017/10/25 15:11:48
But helpful to make the code more readable. Otherw
| |
| 213 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source), | 213 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source), |
| 214 *filename.split('/'))): | 214 *filename.split('/'))): |
| 215 keys = item[1] | |
| 215 locale = sourceFile.split(os.path.sep)[-2] | 216 locale = sourceFile.split(os.path.sep)[-2] |
| 216 targetFile = os.path.join('_locales', locale, 'messages.json') | 217 targetFile = os.path.join('_locales', locale, 'messages.json') |
| 217 data = json.loads(files.get(targetFile, '{}').decode('utf-8')) | 218 data = json.loads(files.get(targetFile, '{}').decode('utf-8')) |
| 218 | 219 |
| 219 try: | 220 try: |
| 220 with io.open(sourceFile, 'r', encoding='utf-8') as handle: | 221 with io.open(sourceFile, 'r', encoding='utf-8') as handle: |
| 221 sourceData = json.load(handle) | 222 sourceData = json.load(handle) |
| 222 | 223 |
| 223 # Resolve wildcard imports | 224 # Resolve wildcard imports |
| 224 if keys == '*': | 225 if keys == '*': |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 if devenv: | 381 if devenv: |
| 381 add_devenv_requirements(files, metadata, params) | 382 add_devenv_requirements(files, metadata, params) |
| 382 | 383 |
| 383 zipdata = files.zipToString() | 384 zipdata = files.zipToString() |
| 384 signature = None | 385 signature = None |
| 385 pubkey = None | 386 pubkey = None |
| 386 if keyFile != None: | 387 if keyFile != None: |
| 387 signature = signBinary(zipdata, keyFile) | 388 signature = signBinary(zipdata, keyFile) |
| 388 pubkey = getPublicKey(keyFile) | 389 pubkey = getPublicKey(keyFile) |
| 389 writePackage(outFile, pubkey, signature, zipdata) | 390 writePackage(outFile, pubkey, signature, zipdata) |
| OLD | NEW |