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

Side by Side 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.
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 | « docs/metadata.edge.example ('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
11 import codecs
12 import subprocess 11 import subprocess
13 import json 12 import json
14 import zipfile 13 import zipfile
15 from StringIO import StringIO 14 from StringIO import StringIO
16 from chainedconfigparser import ChainedConfigParser 15 from chainedconfigparser import ChainedConfigParser
17 16
18 import buildtools 17 import buildtools
19 18
20 19
21 def getDefaultFileName(metadata, version, ext): 20 def getDefaultFileName(metadata, version, ext):
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 # version components. 62 # version components.
64 while version.count('.') < 2: 63 while version.count('.') < 2:
65 version += '.0' 64 version += '.0'
66 version += '.' + buildNum 65 version += '.' + buildNum
67 return version 66 return version
68 67
69 68
70 def getTemplate(template, autoEscape=False): 69 def getTemplate(template, autoEscape=False):
71 import jinja2 70 import jinja2
72 71
73 templatePath = buildtools.__path__[0] 72 template_path = os.path.join(buildtools.__path__[0], 'templates')
73 loader = jinja2.FileSystemLoader(template_path)
74 if autoEscape: 74 if autoEscape:
75 env = jinja2.Environment(loader=jinja2.FileSystemLoader(templatePath), a utoescape=True) 75 env = jinja2.Environment(loader=loader, autoescape=True)
76 else: 76 else:
77 env = jinja2.Environment(loader=jinja2.FileSystemLoader(templatePath)) 77 env = jinja2.Environment(loader=loader)
78 env.filters.update({'json': json.dumps}) 78 env.filters.update({'json': json.dumps})
79 return env.get_template(template) 79 return env.get_template(template)
80 80
81 81
82 class Files(dict): 82 class Files(dict):
83 def __init__(self, includedFiles, ignoredFiles, process=None): 83 def __init__(self, includedFiles, ignoredFiles, process=None):
84 self.includedFiles = includedFiles 84 self.includedFiles = includedFiles
85 self.ignoredFiles = ignoredFiles 85 self.ignoredFiles = ignoredFiles
86 self.process = process 86 self.process = process
87 87
(...skipping 39 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): 137 def zip(self, outFile, sortKey=None, compression=zipfile.ZIP_DEFLATED):
138 zip = zipfile.ZipFile(outFile, 'w', zipfile.ZIP_DEFLATED) 138 with zipfile.ZipFile(outFile, 'w', compression) as zf:
139 names = self.keys() 139 for name in sorted(self, key=sortKey):
140 names.sort(key=sortKey) 140 zf.writestr(name, self[name])
141 for name in names:
142 zip.writestr(name, self[name])
143 zip.close()
144 141
145 def zipToString(self, sortKey=None): 142 def zipToString(self, sortKey=None):
146 buffer = StringIO() 143 buffer = StringIO()
147 self.zip(buffer, sortKey=sortKey) 144 self.zip(buffer, sortKey=sortKey)
148 return buffer.getvalue() 145 return buffer.getvalue()
OLDNEW
« 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