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

Side by Side Diff: packager.py

Issue 29345279: Noissue - Adapt quotes for compliance with our coding style in buildtools (Closed)
Patch Set: Created May 29, 2016, 1:27 p.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') | packagerChrome.py » ('j') | 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 # 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 target, source = item 117 target, source = item
118 118
119 # Make sure the file is inside an included directory 119 # Make sure the file is inside an included directory
120 if '/' in target and not self.isIncluded(target): 120 if '/' in target and not self.isIncluded(target):
121 continue 121 continue
122 parts = source.split('/') 122 parts = source.split('/')
123 path = os.path.join(os.path.dirname(item.source), *parts) 123 path = os.path.join(os.path.dirname(item.source), *parts)
124 if os.path.exists(path): 124 if os.path.exists(path):
125 self.read(path, target) 125 self.read(path, target)
126 else: 126 else:
127 print >>sys.stderr, 'Warning: Mapped file %s doesn\'t exist' % s ource 127 print >>sys.stderr, "Warning: Mapped file %s doesn't exist" % so urce
128 128
129 def preprocess(self, filenames, params={}): 129 def preprocess(self, filenames, params={}):
130 import jinja2 130 import jinja2
131 env = jinja2.Environment() 131 env = jinja2.Environment()
132 132
133 for filename in filenames: 133 for filename in filenames:
134 env.autoescape = os.path.splitext(filename)[1].lower() in ('.html', '.xml') 134 env.autoescape = os.path.splitext(filename)[1].lower() in ('.html', '.xml')
135 template = env.from_string(self[filename].decode('utf-8')) 135 template = env.from_string(self[filename].decode('utf-8'))
136 self[filename] = template.render(params).encode('utf-8') 136 self[filename] = template.render(params).encode('utf-8')
137 137
138 def zip(self, outFile, sortKey=None): 138 def zip(self, outFile, sortKey=None):
139 zip = zipfile.ZipFile(outFile, 'w', zipfile.ZIP_DEFLATED) 139 zip = zipfile.ZipFile(outFile, 'w', zipfile.ZIP_DEFLATED)
140 names = self.keys() 140 names = self.keys()
141 names.sort(key=sortKey) 141 names.sort(key=sortKey)
142 for name in names: 142 for name in names:
143 zip.writestr(name, self[name]) 143 zip.writestr(name, self[name])
144 zip.close() 144 zip.close()
145 145
146 def zipToString(self, sortKey=None): 146 def zipToString(self, sortKey=None):
147 buffer = StringIO() 147 buffer = StringIO()
148 self.zip(buffer, sortKey=sortKey) 148 self.zip(buffer, sortKey=sortKey)
149 return buffer.getvalue() 149 return buffer.getvalue()
OLDNEW
« no previous file with comments | « localeTools.py ('k') | packagerChrome.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld