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

Unified Diff: packager.py

Issue 9158185: Implemented mapping of files from subrepositories (Closed)
Patch Set: Created Jan. 14, 2013, 2:43 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 | « no previous file | 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
@@ -13,17 +13,17 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
# Note: These are the base functions common to all packagers, the actual
# packagers are implemented in packagerGecko and packagerChrome.
-import os, re, codecs, subprocess, json, zipfile, jinja2
+import sys, os, re, codecs, subprocess, json, zipfile, jinja2
from StringIO import StringIO
from ConfigParser import SafeConfigParser
import buildtools
def getDefaultFileName(baseDir, metadata, version, ext):
return os.path.join(baseDir, '%s-%s.%s' % (metadata.get('general', 'basename'), version, ext))
@@ -86,19 +86,33 @@ class Files(dict):
def read(self, path, relpath='', skip=None):
if os.path.isdir(path):
for file in os.listdir(path):
name = relpath + ('/' if relpath != '' else '') + file
if (skip == None or file not in skip) and self.isIncluded(name):
self.read(os.path.join(path, file), name)
else:
file = open(path, 'rb')
+ if relpath in self:
+ print >>sys.stderr, 'Warning: File %s defined multiple times' % relpath
self[relpath] = file.read()
file.close()
+ def readMappedFiles(self, baseDir, mappings):
+ for target, source in mappings:
+ # Make sure the file is inside an included directory
+ if '/' in target and not self.isIncluded(target):
+ continue
+ parts = source.split('/')
+ path = os.path.join(baseDir, *parts)
+ if os.path.exists(path):
+ self.read(path, target)
+ else:
+ print >>sys.stderr, 'Warning: Mapped file %s doesn\'t exist' % source
+
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:
data = self[name]
if self.process:
data = self.process(name, data)
« no previous file with comments | « no previous file | packagerChrome.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld