| 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 base64 | 5 import base64 | 
| 6 import collections | 6 import collections | 
| 7 import ConfigParser | 7 import ConfigParser | 
| 8 import json | 8 import json | 
| 9 import os | 9 import os | 
| 10 import re | 10 import re | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 85         homepage=get_optional('general', 'homepage'), | 85         homepage=get_optional('general', 'homepage'), | 
| 86         updateURL=get_optional('general', 'updateURL'), | 86         updateURL=get_optional('general', 'updateURL'), | 
| 87         allowedDomains=allowedDomains, | 87         allowedDomains=allowedDomains, | 
| 88         allowAllDomains=allowAllDomains, | 88         allowAllDomains=allowAllDomains, | 
| 89         allowSecurePages=allowSecurePages, | 89         allowSecurePages=allowSecurePages, | 
| 90         startScripts=(get_optional('contentScripts', 'document_start') or '').sp
     lit(), | 90         startScripts=(get_optional('contentScripts', 'document_start') or '').sp
     lit(), | 
| 91         endScripts=(get_optional('contentScripts', 'document_end') or '').split(
     ), | 91         endScripts=(get_optional('contentScripts', 'document_end') or '').split(
     ), | 
| 92         menus=parse_section('menus', 2), | 92         menus=parse_section('menus', 2), | 
| 93         toolbarItems=parse_section('toolbar_items'), | 93         toolbarItems=parse_section('toolbar_items'), | 
| 94         popovers=parse_section('popovers'), | 94         popovers=parse_section('popovers'), | 
| 95         developerIdentifier=params.get('developerIdentifier') | 95         developerIdentifier=params.get('developerIdentifier'), | 
| 96     ).encode('utf-8') | 96     ).encode('utf-8') | 
| 97 | 97 | 
| 98 | 98 | 
| 99 def createInfoModule(params): | 99 def createInfoModule(params): | 
| 100     template = getTemplate('safariInfo.js.tmpl') | 100     template = getTemplate('safariInfo.js.tmpl') | 
| 101     return template.render(params).encode('utf-8') | 101     return template.render(params).encode('utf-8') | 
| 102 | 102 | 
| 103 | 103 | 
| 104 def _get_sequence(data): | 104 def _get_sequence(data): | 
| 105     from Crypto.Util import asn1 | 105     from Crypto.Util import asn1 | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 153             module_name = os.path.splitext(os.path.basename(input_filename))[0] | 153             module_name = os.path.splitext(os.path.basename(input_filename))[0] | 
| 154             prefix = os.path.basename(os.path.dirname(input_filename)) | 154             prefix = os.path.basename(os.path.dirname(input_filename)) | 
| 155             if prefix != 'lib': | 155             if prefix != 'lib': | 
| 156                 module_name = '{}_{}'.format(prefix, module_name) | 156                 module_name = '{}_{}'.format(prefix, module_name) | 
| 157             with open(os.path.join(base_dir, input_filename), 'r') as file: | 157             with open(os.path.join(base_dir, input_filename), 'r') as file: | 
| 158                 modules.append((module_name, file.read().decode('utf-8'))) | 158                 modules.append((module_name, file.read().decode('utf-8'))) | 
| 159             files.pop(input_filename, None) | 159             files.pop(input_filename, None) | 
| 160 | 160 | 
| 161         files[filename] = template.render( | 161         files[filename] = template.render( | 
| 162             args=current_args, | 162             args=current_args, | 
| 163             modules=modules | 163             modules=modules, | 
| 164         ).encode('utf-8') | 164         ).encode('utf-8') | 
| 165 | 165 | 
| 166 | 166 | 
| 167 def createBuild(baseDir, type, outFile=None, buildNum=None, releaseBuild=False, 
     keyFile=None, devenv=False): | 167 def createBuild(baseDir, type, outFile=None, buildNum=None, releaseBuild=False, 
     keyFile=None, devenv=False): | 
| 168     metadata = readMetadata(baseDir, type) | 168     metadata = readMetadata(baseDir, type) | 
| 169     version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum) | 169     version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum) | 
| 170 | 170 | 
| 171     if not outFile: | 171     if not outFile: | 
| 172         outFile = getDefaultFileName(metadata, version, 'safariextz' if keyFile 
     else 'zip') | 172         outFile = getDefaultFileName(metadata, version, 'safariextz' if keyFile 
     else 'zip') | 
| 173 | 173 | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 185                   process=lambda path, data: processFile(path, data, params)) | 185                   process=lambda path, data: processFile(path, data, params)) | 
| 186     files.readMappedFiles(mapped) | 186     files.readMappedFiles(mapped) | 
| 187     files.read(baseDir, skip=[opt for opt, _ in mapped]) | 187     files.read(baseDir, skip=[opt for opt, _ in mapped]) | 
| 188 | 188 | 
| 189     if metadata.has_section('convert_js'): | 189     if metadata.has_section('convert_js'): | 
| 190         convertJS(params, files) | 190         convertJS(params, files) | 
| 191 | 191 | 
| 192     if metadata.has_section('preprocess'): | 192     if metadata.has_section('preprocess'): | 
| 193         files.preprocess( | 193         files.preprocess( | 
| 194             [f for f, _ in metadata.items('preprocess')], | 194             [f for f, _ in metadata.items('preprocess')], | 
| 195             {'needsExt': True} | 195             {'needsExt': True}, | 
| 196         ) | 196         ) | 
| 197 | 197 | 
| 198     if metadata.has_section('import_locales'): | 198     if metadata.has_section('import_locales'): | 
| 199         import_locales(params, files) | 199         import_locales(params, files) | 
| 200 | 200 | 
| 201     if metadata.has_option('general', 'testScripts'): | 201     if metadata.has_option('general', 'testScripts'): | 
| 202         files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmp
     l', | 202         files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmp
     l', | 
| 203                                                      ('general', 'testScripts')) | 203                                                      ('general', 'testScripts')) | 
| 204 | 204 | 
| 205     if keyFile: | 205     if keyFile: | 
| 206         from buildtools import xarfile | 206         from buildtools import xarfile | 
| 207         certs, key = xarfile.read_certificates_and_key(keyFile) | 207         certs, key = xarfile.read_certificates_and_key(keyFile) | 
| 208         params['developerIdentifier'] = get_developer_identifier(certs) | 208         params['developerIdentifier'] = get_developer_identifier(certs) | 
| 209 | 209 | 
| 210     files['lib/info.js'] = createInfoModule(params) | 210     files['lib/info.js'] = createInfoModule(params) | 
| 211     files['background.html'] = createScriptPage(params, 'background.html.tmpl', | 211     files['background.html'] = createScriptPage(params, 'background.html.tmpl', | 
| 212                                                 ('general', 'backgroundScripts')
     ) | 212                                                 ('general', 'backgroundScripts')
     ) | 
| 213     files['Info.plist'] = createManifest(params, files) | 213     files['Info.plist'] = createManifest(params, files) | 
| 214 | 214 | 
| 215     dirname = metadata.get('general', 'basename') + '.safariextension' | 215     dirname = metadata.get('general', 'basename') + '.safariextension' | 
| 216     for filename in files.keys(): | 216     for filename in files.keys(): | 
| 217         files[os.path.join(dirname, filename)] = files.pop(filename) | 217         files[os.path.join(dirname, filename)] = files.pop(filename) | 
| 218 | 218 | 
| 219     if not devenv and keyFile: | 219     if not devenv and keyFile: | 
| 220         from buildtools import xarfile | 220         from buildtools import xarfile | 
| 221         xarfile.create(outFile, files, keyFile) | 221         xarfile.create(outFile, files, keyFile) | 
| 222     else: | 222     else: | 
| 223         files.zip(outFile) | 223         files.zip(outFile) | 
| OLD | NEW | 
|---|