Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: build/android/resource_sizes.py

Issue 2565303003: 🎄 Fix resource_sizes.py when no pak files exist. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Prints the size of each given file and optionally computes the size of 6 """Prints the size of each given file and optionally computes the size of
7 libchrome.so without the dependencies added for building with android NDK. 7 libchrome.so without the dependencies added for building with android NDK.
8 Also breaks down the contents of the APK to determine the installed size 8 Also breaks down the contents of the APK to determine the installed size
9 and assign size contributions to different classes of file. 9 and assign size contributions to different classes of file.
10 """ 10 """
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 self._extracted = [] 177 self._extracted = []
178 178
179 def AddZipInfo(self, zip_info, extracted=False): 179 def AddZipInfo(self, zip_info, extracted=False):
180 self._zip_infos.append(zip_info) 180 self._zip_infos.append(zip_info)
181 self._extracted.append(extracted) 181 self._extracted.append(extracted)
182 182
183 def GetNumEntries(self): 183 def GetNumEntries(self):
184 return len(self._zip_infos) 184 return len(self._zip_infos)
185 185
186 def FindByPattern(self, pattern): 186 def FindByPattern(self, pattern):
187 return next(i for i in self._zip_infos if re.match(pattern, i.filename)) 187 return next((i for i in self._zip_infos if re.match(pattern, i.filename)),
188 None)
188 189
189 def FindLargest(self): 190 def FindLargest(self):
190 return max(self._zip_infos, key=lambda i: i.file_size) 191 return max(self._zip_infos, key=lambda i: i.file_size)
191 192
192 def ComputeZippedSize(self): 193 def ComputeZippedSize(self):
193 return sum(i.compress_size for i in self._zip_infos) 194 return sum(i.compress_size for i in self._zip_infos)
194 195
195 def ComputeUncompressedSize(self): 196 def ComputeUncompressedSize(self):
196 return sum(i.file_size for i in self._zip_infos) 197 return sum(i.file_size for i in self._zip_infos)
197 198
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 590
590 if chartjson: 591 if chartjson:
591 results_path = os.path.join(options.output_dir, 'results-chart.json') 592 results_path = os.path.join(options.output_dir, 'results-chart.json')
592 logging.critical('Dumping json to %s', results_path) 593 logging.critical('Dumping json to %s', results_path)
593 with open(results_path, 'w') as json_file: 594 with open(results_path, 'w') as json_file:
594 json.dump(chartjson, json_file) 595 json.dump(chartjson, json_file)
595 596
596 597
597 if __name__ == '__main__': 598 if __name__ == '__main__':
598 sys.exit(main(sys.argv)) 599 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698