Lines Matching refs:path

27     for path in input_paths:
28 if _is_zip_file(path):
29 entries = _extract_zip_entries(path)
30 new_metadata.add_zip_file(path, entries)
32 new_metadata.add_file(path, _md5_for_path(path))
38 if os.path.exists(record_path):
92 x for x in output_paths if force or not os.path.exists(x)
159 for path in self.iter_modified_paths():
160 if any(self.iter_removed_subpaths(path)):
168 def iter_all_subpaths(self, path):
170 return self.new_metadata.iter_subpaths(path)
174 for path in self.new_metadata.iter_paths():
175 if self._get_old_tag(path) is None:
176 yield path
178 def iter_added_subpaths(self, path):
180 for subpath in self.new_metadata.iter_subpaths(path):
181 if self._get_old_tag(path, subpath) is None:
187 for path in self.old_metadata.iter_paths():
188 if self.new_metadata.get_tag(path) is None:
189 yield path
191 def iter_removed_subpaths(self, path):
194 for subpath in self.old_metadata.iter_subpaths(path):
195 if self.new_metadata.get_tag(path, subpath) is None:
200 for path in self.new_metadata.iter_paths():
201 old_tag = self._get_old_tag(path)
202 new_tag = self.new_metadata.get_tag(path)
204 yield path
206 def iter_modified_subpaths(self, path):
208 for subpath in self.new_metadata.iter_subpaths(path):
209 old_tag = self._get_old_tag(path, subpath)
210 new_tag = self.new_metadata.get_tag(path, subpath)
220 def iter_changed_subpaths(self, path):
222 return itertools.chain(self.iter_removed_subpaths(path),
223 self.iter_modified_subpaths(path),
224 self.iter_added_subpaths(path))
246 for path in self.iter_modified_paths():
247 lines.append('Modified: {}'.format(path))
249 p for p in self.iter_added_subpaths(path)))
251 p for p in self.iter_removed_subpaths(path)))
253 p for p in self.iter_modified_subpaths(path)))
263 def _get_old_tag(self, path, subpath=None):
264 return self.old_metadata and self.old_metadata.get_tag(path, subpath)
274 # Map of (path, subpath) -> entry. Created upon first call to _get_entry().
302 def add_file(self, path, tag):
306 path: Path to the file.
311 'path': path,
315 def add_zip_file(self, path, entries):
319 path: Path to the file.
326 'path':
327 path,
331 "path": e[0],
354 def get_tag(self, path, subpath=None):
355 """Returns the tag for the given path / subpath."""
356 ret = self._get_entry(path, subpath)
361 return (e['path'] for e in self._files)
363 def iter_subpaths(self, path):
366 If the given path is not a zip file or doesn't exist, returns an empty
369 outer_entry = self._get_entry(path)
373 return (entry['path'] for entry in subentries)
380 def _get_entry(self, path, subpath=None):
381 """Returns the JSON entry for the given path / subpath."""
385 self._file_map[(entry['path'], None)] = entry
387 self._file_map[(entry['path'],
388 subentry['path'])] = subentry
389 return self._file_map.get((path, subpath))
392 def _update_md5_for_file(md5, path, block_size=2**16):
394 if os.path.islink(path):
395 linkto = os.readlink(path)
396 if not os.path.exists(linkto):
400 with open(path, 'rb') as infile:
411 _update_md5_for_file(md5, os.path.join(root, f))
414 def _md5_for_path(path):
416 if os.path.isdir(path):
417 _update_md5_for_directory(md5, path)
419 _update_md5_for_file(md5, path)
431 def _is_zip_file(path):
433 return path[-4:] in ('.zip')
436 def _extract_zip_entries(path):
437 """Returns a list of (path, CRC32) of all files within |path|."""
439 with zipfile.ZipFile(path) as zip_file: