~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: Aaron Bentley
  • Date: 2007-08-16 00:14:26 UTC
  • mto: This revision was merged to the branch mainline in revision 2735.
  • Revision ID: aaron.bentley@utoronto.ca-20070816001426-8aqbepjh4b3qu8o4
Implement Tree.extract_files

Show diffs side-by-side

added added

removed removed

Lines of Context:
225
225
    def get_file_by_path(self, path):
226
226
        return self.get_file(self._inventory.path2id(path))
227
227
 
 
228
    def extract_files_bytes(self, callable, desired_files):
 
229
        """Provide file contents to the callable, as an iterator of bytes.
 
230
 
 
231
        The default implementation just does get_file().
 
232
        :param callable: A callable that accepts (bytes_iterator,
 
233
            callable_data)
 
234
        :param desired_files: a list of (file_id, callable_data) pairs
 
235
        """
 
236
        for file_id, callable_data in desired_files:
 
237
            cur_file = self.get_file(file_id)
 
238
            try:
 
239
                callable(cur_file, callable_data)
 
240
            finally:
 
241
                cur_file.close()
 
242
 
228
243
    def get_symlink_target(self, file_id):
229
244
        """Get the target for a given file_id.
230
245