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

Unified Diff: packager.py

Issue 29345751: Issue 4028 - Add support for Edge extensions to buildtools (Closed)
Patch Set: Address Windows Store issues with blockmap and devbuild display name Created Oct. 14, 2016, 12:07 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « docs/metadata.edge.example ('k') | packagerChrome.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packager.py
===================================================================
--- a/packager.py
+++ b/packager.py
@@ -3,17 +3,16 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Note: These are the base functions common to all packagers, the actual
# packagers are implemented in packagerGecko and packagerChrome.
import sys
import os
import re
-import codecs
import subprocess
import json
import zipfile
from StringIO import StringIO
from chainedconfigparser import ChainedConfigParser
import buildtools
@@ -65,21 +64,22 @@
version += '.0'
version += '.' + buildNum
return version
def getTemplate(template, autoEscape=False):
import jinja2
- templatePath = buildtools.__path__[0]
+ template_path = os.path.join(buildtools.__path__[0], 'templates')
+ loader = jinja2.FileSystemLoader(template_path)
if autoEscape:
- env = jinja2.Environment(loader=jinja2.FileSystemLoader(templatePath), autoescape=True)
+ env = jinja2.Environment(loader=loader, autoescape=True)
else:
- env = jinja2.Environment(loader=jinja2.FileSystemLoader(templatePath))
+ env = jinja2.Environment(loader=loader)
env.filters.update({'json': json.dumps})
return env.get_template(template)
class Files(dict):
def __init__(self, includedFiles, ignoredFiles, process=None):
self.includedFiles = includedFiles
self.ignoredFiles = ignoredFiles
@@ -129,20 +129,17 @@
import jinja2
env = jinja2.Environment()
for filename in filenames:
env.autoescape = os.path.splitext(filename)[1].lower() in ('.html', '.xml')
template = env.from_string(self[filename].decode('utf-8'))
self[filename] = template.render(params).encode('utf-8')
- def zip(self, outFile, sortKey=None):
- zip = zipfile.ZipFile(outFile, 'w', zipfile.ZIP_DEFLATED)
- names = self.keys()
- names.sort(key=sortKey)
- for name in names:
- zip.writestr(name, self[name])
- zip.close()
+ def zip(self, outFile, sortKey=None, compression=zipfile.ZIP_DEFLATED):
+ with zipfile.ZipFile(outFile, 'w', compression) as zf:
+ for name in sorted(self, key=sortKey):
+ zf.writestr(name, self[name])
def zipToString(self, sortKey=None):
buffer = StringIO()
self.zip(buffer, sortKey=sortKey)
return buffer.getvalue()
« no previous file with comments | « docs/metadata.edge.example ('k') | packagerChrome.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld