Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: packagerSafari.py

Issue 29420565: Noissue - Remove some dead code (Closed) Base URL: https://hg.adblockplus.org/buildtools
Patch Set: Created April 24, 2017, 9:43 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « localeTools.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ConfigParser 6 import ConfigParser
7 import json 7 import json
8 import os 8 import os
9 import re 9 import re
10 from urlparse import urlparse 10 from urlparse import urlparse
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 popovers=parse_section('popovers'), 93 popovers=parse_section('popovers'),
94 developerIdentifier=params.get('developerIdentifier') 94 developerIdentifier=params.get('developerIdentifier')
95 ).encode('utf-8') 95 ).encode('utf-8')
96 96
97 97
98 def createInfoModule(params): 98 def createInfoModule(params):
99 template = getTemplate('safariInfo.js.tmpl') 99 template = getTemplate('safariInfo.js.tmpl')
100 return template.render(params).encode('utf-8') 100 return template.render(params).encode('utf-8')
101 101
102 102
103 def fixAbsoluteUrls(files):
104 for filename, content in files.iteritems():
105 if os.path.splitext(filename)[1].lower() == '.html':
106 files[filename] = re.sub(
107 r'(<[^<>]*?\b(?:href|src)\s*=\s*["\']?)\/+',
108 r'\1' + '/'.join(['..'] * filename.count('/') + ['']),
109 content, re.S | re.I
110 )
111
112
113 def _get_sequence(data): 103 def _get_sequence(data):
114 from Crypto.Util import asn1 104 from Crypto.Util import asn1
115 sequence = asn1.DerSequence() 105 sequence = asn1.DerSequence()
116 sequence.decode(data) 106 sequence.decode(data)
117 return sequence 107 return sequence
118 108
119 109
120 def get_developer_identifier(certs): 110 def get_developer_identifier(certs):
121 for cert in certs: 111 for cert in certs:
122 # See https://tools.ietf.org/html/rfc5280#section-4 112 # See https://tools.ietf.org/html/rfc5280#section-4
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if keyFile: 163 if keyFile:
174 from buildtools import xarfile 164 from buildtools import xarfile
175 certs, key = xarfile.read_certificates_and_key(keyFile) 165 certs, key = xarfile.read_certificates_and_key(keyFile)
176 params['developerIdentifier'] = get_developer_identifier(certs) 166 params['developerIdentifier'] = get_developer_identifier(certs)
177 167
178 files['lib/info.js'] = createInfoModule(params) 168 files['lib/info.js'] = createInfoModule(params)
179 files['background.html'] = createScriptPage(params, 'background.html.tmpl', 169 files['background.html'] = createScriptPage(params, 'background.html.tmpl',
180 ('general', 'backgroundScripts') ) 170 ('general', 'backgroundScripts') )
181 files['Info.plist'] = createManifest(params, files) 171 files['Info.plist'] = createManifest(params, files)
182 172
183 fixAbsoluteUrls(files)
184
185 dirname = metadata.get('general', 'basename') + '.safariextension' 173 dirname = metadata.get('general', 'basename') + '.safariextension'
186 for filename in files.keys(): 174 for filename in files.keys():
187 files[os.path.join(dirname, filename)] = files.pop(filename) 175 files[os.path.join(dirname, filename)] = files.pop(filename)
188 176
189 if not devenv and keyFile: 177 if not devenv and keyFile:
190 from buildtools import xarfile 178 from buildtools import xarfile
191 xarfile.create(outFile, files, keyFile) 179 xarfile.create(outFile, files, keyFile)
192 else: 180 else:
193 files.zip(outFile) 181 files.zip(outFile)
OLDNEW
« no previous file with comments | « localeTools.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld