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

Delta Between Two Patch Sets: packager.py

Issue 29333368: Issue 3498 - Improve file mapping / skipping logic (Closed)
Left Patch Set: Created Jan. 12, 2016, 9:56 a.m.
Right Patch Set: Fixed typo in Gecko packager Created Jan. 13, 2016, 11:10 a.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 | « no previous file | 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 # coding: utf-8 1 # coding: utf-8
2 2
3 # This Source Code Form is subject to the terms of the Mozilla Public 3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 6
7 # Note: These are the base functions common to all packagers, the actual 7 # Note: These are the base functions common to all packagers, the actual
8 # packagers are implemented in packagerGecko and packagerChrome. 8 # packagers are implemented in packagerGecko and packagerChrome.
9 9
10 import sys, os, re, codecs, subprocess, json, zipfile 10 import sys, os, re, codecs, subprocess, json, zipfile
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 def isIncluded(self, relpath): 82 def isIncluded(self, relpath):
83 parts = relpath.split('/') 83 parts = relpath.split('/')
84 if not parts[0] in self.includedFiles: 84 if not parts[0] in self.includedFiles:
85 return False 85 return False
86 for part in parts: 86 for part in parts:
87 if part in self.ignoredFiles: 87 if part in self.ignoredFiles:
88 return False 88 return False
89 return True 89 return True
90 90
91 def read(self, path, relpath='', skip=None): 91 def read(self, path, relpath='', skip=()):
92 if os.path.isdir(path): 92 if os.path.isdir(path):
93 for file in os.listdir(path): 93 for file in os.listdir(path):
94 name = relpath + ('/' if relpath != '' else '') + file 94 name = relpath + ('/' if relpath != '' else '') + file
95 if (skip == None or file not in skip) and self.isIncluded(name): 95 if name not in skip and self.isIncluded(name):
96 self.read(os.path.join(path, file), name, skip) 96 self.read(os.path.join(path, file), name, skip)
Wladimir Palant 2016/01/12 12:16:33 No, skip as implemented right now is only meant to
kzar 2016/01/12 13:09:47 Done.
97 else: 97 else:
98 with open(path, 'rb') as file: 98 with open(path, 'rb') as file:
99 if relpath in self: 99 if relpath in self:
100 print >>sys.stderr, 'Warning: File %s defined multiple times' % relpat h 100 print >>sys.stderr, 'Warning: File %s defined multiple times' % relpat h
101 self[relpath] = file.read() 101 self[relpath] = file.read()
102 102
103 def readMappedFiles(self, mappings): 103 def readMappedFiles(self, mappings):
104 for item in mappings: 104 for item in mappings:
105 target, source = item 105 target, source = item
106 106
(...skipping 21 matching lines...) Expand all
128 names = self.keys() 128 names = self.keys()
129 names.sort(key=sortKey) 129 names.sort(key=sortKey)
130 for name in names: 130 for name in names:
131 zip.writestr(name, self[name]) 131 zip.writestr(name, self[name])
132 zip.close() 132 zip.close()
133 133
134 def zipToString(self, sortKey=None): 134 def zipToString(self, sortKey=None):
135 buffer = StringIO() 135 buffer = StringIO()
136 self.zip(buffer, sortKey=sortKey) 136 self.zip(buffer, sortKey=sortKey)
137 return buffer.getvalue() 137 return buffer.getvalue()
LEFTRIGHT
« no previous file | packagerChrome.py » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld