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

Side by Side Diff: packager.py

Issue 29825555: Issue 6291 - add ManifoldJS packaging for Edge (Closed) Base URL: https://hg.adblockplus.org/buildtools/file/9a56d76cd951
Patch Set: Created July 9, 2018, 7:52 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 | « package.json ('k') | packagerEdge.py » ('j') | packagerEdge.py » ('J')
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 # Note: These are the base functions common to all packagers, the actual 5 # Note: These are the base functions common to all packagers, the actual
6 # packagers are implemented in packagerChrome and packagerEdge. 6 # packagers are implemented in packagerChrome and packagerEdge.
7 7
8 import sys 8 import sys
9 import os 9 import os
10 import re 10 import re
11 import subprocess 11 import subprocess
12 import tempfile
12 import json 13 import json
13 import zipfile 14 import zipfile
14 from StringIO import StringIO 15 from StringIO import StringIO
15 from chainedconfigparser import ChainedConfigParser 16 from chainedconfigparser import ChainedConfigParser
16 17
17 import buildtools 18 import buildtools
18 19
19 EXTENSIONS = { 20 EXTENSIONS = {
20 'edge': 'appx', 21 'edge': 'appx',
21 'gecko': 'xpi', 22 'gecko': 'xpi',
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 for filename in filenames: 161 for filename in filenames:
161 env.autoescape = os.path.splitext(filename)[1].lower() in ('.html', '.xml') 162 env.autoescape = os.path.splitext(filename)[1].lower() in ('.html', '.xml')
162 template = env.from_string(self[filename].decode('utf-8')) 163 template = env.from_string(self[filename].decode('utf-8'))
163 self[filename] = template.render(params).encode('utf-8') 164 self[filename] = template.render(params).encode('utf-8')
164 165
165 def zip(self, outFile, sortKey=None, compression=zipfile.ZIP_DEFLATED): 166 def zip(self, outFile, sortKey=None, compression=zipfile.ZIP_DEFLATED):
166 with zipfile.ZipFile(outFile, 'w', compression) as zf: 167 with zipfile.ZipFile(outFile, 'w', compression) as zf:
167 for name in sorted(self, key=sortKey): 168 for name in sorted(self, key=sortKey):
168 zf.writestr(name, self[name]) 169 zf.writestr(name, self[name])
169 170
171 def to_tmp_folder(self, subfolder=None):
Sebastian Noack 2018/07/09 12:35:19 See the devenv() function in the "build" module. T
tlucas 2018/07/09 13:23:56 Done.
172 tmp_dir = tempfile.mkdtemp('adblockplus_package')
173 if subfolder:
174 cwtd = os.path.join(tmp_dir, subfolder)
175 os.makedirs(cwtd)
176 else:
177 cwtd = tmp_dir
178
179 for name in sorted(self):
180 dest = os.path.join(cwtd, name)
181 try:
182 os.makedirs(os.path.dirname(dest))
183 except OSError:
184 pass
185
186 with open(dest, 'w') as fp:
187 fp.write(self[name])
188 return tmp_dir
189
170 def zipToString(self, sortKey=None): 190 def zipToString(self, sortKey=None):
171 buffer = StringIO() 191 buffer = StringIO()
172 self.zip(buffer, sortKey=sortKey) 192 self.zip(buffer, sortKey=sortKey)
173 return buffer.getvalue() 193 return buffer.getvalue()
OLDNEW
« no previous file with comments | « package.json ('k') | packagerEdge.py » ('j') | packagerEdge.py » ('J')

Powered by Google App Engine
This is Rietveld