OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import difflib | 5 import difflib |
6 import hashlib | 6 import hashlib |
7 import itertools | 7 import itertools |
8 import json | 8 import json |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 not self.old_metadata or | 118 not self.old_metadata or |
119 self.old_metadata.StringsMd5() != self.new_metadata.StringsMd5()): | 119 self.old_metadata.StringsMd5() != self.new_metadata.StringsMd5()): |
120 return False | 120 return False |
121 if any(self.IterRemovedPaths()): | 121 if any(self.IterRemovedPaths()): |
122 return False | 122 return False |
123 for path in self.IterModifiedPaths(): | 123 for path in self.IterModifiedPaths(): |
124 if any(self.IterRemovedSubpaths(path)): | 124 if any(self.IterRemovedSubpaths(path)): |
125 return False | 125 return False |
126 return True | 126 return True |
127 | 127 |
| 128 def IterAllPaths(self): |
| 129 """Generator for paths.""" |
| 130 return self.new_metadata.IterPaths(); |
| 131 |
| 132 def IterAllSubpaths(self, path): |
| 133 """Generator for subpaths.""" |
| 134 return self.new_metadata.IterSubpaths(path); |
| 135 |
128 def IterAddedPaths(self): | 136 def IterAddedPaths(self): |
129 """Generator for paths that were added.""" | 137 """Generator for paths that were added.""" |
130 for path in self.new_metadata.IterPaths(): | 138 for path in self.new_metadata.IterPaths(): |
131 if self._GetOldTag(path) is None: | 139 if self._GetOldTag(path) is None: |
132 yield path | 140 yield path |
133 | 141 |
134 def IterAddedSubpaths(self, path): | 142 def IterAddedSubpaths(self, path): |
135 """Generator for paths that were added within the given zip file.""" | 143 """Generator for paths that were added within the given zip file.""" |
136 for subpath in self.new_metadata.IterSubpaths(path): | 144 for subpath in self.new_metadata.IterSubpaths(path): |
137 if self._GetOldTag(path, subpath) is None: | 145 if self._GetOldTag(path, subpath) is None: |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 def _ExtractZipEntries(path): | 401 def _ExtractZipEntries(path): |
394 """Returns a list of (path, CRC32) of all files within |path|.""" | 402 """Returns a list of (path, CRC32) of all files within |path|.""" |
395 entries = [] | 403 entries = [] |
396 with zipfile.ZipFile(path) as zip_file: | 404 with zipfile.ZipFile(path) as zip_file: |
397 for zip_info in zip_file.infolist(): | 405 for zip_info in zip_file.infolist(): |
398 # Skip directories and empty files. | 406 # Skip directories and empty files. |
399 if zip_info.CRC: | 407 if zip_info.CRC: |
400 entries.append( | 408 entries.append( |
401 (zip_info.filename, zip_info.CRC + zip_info.compress_type)) | 409 (zip_info.filename, zip_info.CRC + zip_info.compress_type)) |
402 return entries | 410 return entries |
OLD | NEW |