~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store.py

  • Committer: John Arbash Meinel
  • Date: 2005-07-12 07:17:28 UTC
  • mto: (1185.11.1)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: john@arbash-meinel.com-20050712071728-ab7234b176ee64ed
Moving the multi-get functionality higher up into the Branch class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
        for fileid, f in entries:
80
80
            self.add(fileid, f)
81
81
 
 
82
    def has(self, fileids):
 
83
        """Return True/False for each entry in fileids.
 
84
 
 
85
        :param fileids: A List or generator yielding file ids.
 
86
        :return: A generator or list returning True/False for each entry.
 
87
        """
 
88
        for fileid in fileids:
 
89
            if fileid in self:
 
90
                yield True
 
91
            else:
 
92
                yield False
 
93
 
 
94
    def get(self, fileids, pb=None):
 
95
        """Return a set of files, one for each requested entry."""
 
96
        for fileid in fileids:
 
97
            yield self[fileid]
 
98
 
82
99
    def copy_multi(self, other, ids):
83
100
        """Copy texts for ids from other into self.
84
101
 
234
251
        fn = self._relpath(fileid)
235
252
        return self._transport.has(fn)
236
253
 
237
 
    # TODO: Guard against the same thing being stored twice, compressed and uncompresse
 
254
    def has(self, fileids, pb=None):
 
255
        """Return True/False for each entry in fileids.
 
256
 
 
257
        :param fileids: A List or generator yielding file ids.
 
258
        :return: A generator or list returning True/False for each entry.
 
259
        """
 
260
        relpaths = [self._relpath(fid) for fid in fileids]
 
261
        return self._transport.has_multi(relpaths, pb=pb)
 
262
 
 
263
    def get(self, fileids, pb=None):
 
264
        """Return a set of files, one for each requested entry."""
 
265
        rel_paths = [self._relpath(fid) for fid in fileids]
 
266
        for f in self._transport.get_multi(rel_paths, pb=pb):
 
267
            if hasattr(f, 'tell'):
 
268
                yield gzip.GzipFile(mode='rb', fileobj=f)
 
269
            else:
 
270
                from cStringIO import StringIO
 
271
                sio = StringIO(f.read())
 
272
                yield gzip.GzipFile(mode='rb', fileobj=sio)
238
273
 
239
274
    def __iter__(self):
240
275
        # TODO: case-insensitive?