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

Delta Between Two Patch Sets: packager.py

Issue 29345751: Issue 4028 - Add support for Edge extensions to buildtools (Closed)
Left Patch Set: Address comments on patch set 7 Created Oct. 4, 2016, 2:37 p.m.
Right Patch Set: Address Windows Store issues with blockmap and devbuild display name Created Oct. 14, 2016, 12:07 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « docs/metadata.edge.example ('k') | packagerChrome.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 packagerGecko and packagerChrome. 6 # packagers are implemented in packagerGecko and packagerChrome.
7 7
8 import sys 8 import sys
9 import os 9 import os
10 import re 10 import re
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 def preprocess(self, filenames, params={}): 128 def preprocess(self, filenames, params={}):
129 import jinja2 129 import jinja2
130 env = jinja2.Environment() 130 env = jinja2.Environment()
131 131
132 for filename in filenames: 132 for filename in filenames:
133 env.autoescape = os.path.splitext(filename)[1].lower() in ('.html', '.xml') 133 env.autoescape = os.path.splitext(filename)[1].lower() in ('.html', '.xml')
134 template = env.from_string(self[filename].decode('utf-8')) 134 template = env.from_string(self[filename].decode('utf-8'))
135 self[filename] = template.render(params).encode('utf-8') 135 self[filename] = template.render(params).encode('utf-8')
136 136
137 def zip(self, outFile, sortKey=None, compress=True): 137 def zip(self, outFile, sortKey=None, compression=zipfile.ZIP_DEFLATED):
Sebastian Noack 2016/10/04 19:58:05 Perhaps it is a little simpler if you just pass th
Vasily Kuznetsov 2016/10/11 15:58:28 Done.
138 compression = zipfile.ZIP_DEFLATED if compress else zipfile.ZIP_STORED 138 with zipfile.ZipFile(outFile, 'w', compression) as zf:
139 zf = zipfile.ZipFile(outFile, 'w', compression) 139 for name in sorted(self, key=sortKey):
Sebastian Noack 2016/10/04 19:58:05 While changing this code anyway, use with-statemen
Vasily Kuznetsov 2016/10/11 15:58:27 Done.
140 for name in sorted(self, key=sortKey): 140 zf.writestr(name, self[name])
141 zf.writestr(name, self[name])
142 zf.close()
143 141
144 def zipToString(self, sortKey=None): 142 def zipToString(self, sortKey=None):
145 buffer = StringIO() 143 buffer = StringIO()
146 self.zip(buffer, sortKey=sortKey) 144 self.zip(buffer, sortKey=sortKey)
147 return buffer.getvalue() 145 return buffer.getvalue()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld