150
150
raise NotImplementedError
152
def get_partial(self, relpath, portion):
153
"""Get just part of a file.
155
:param relpath: Path to the file, relative to base
156
:param portion: A tuple of [start,length).
157
Length can be -1 indicating copy until the end
158
of the file. If the file ends before length bytes,
159
just the set of bytes will be returned (think read())
160
:return: A file-like object containing at least the specified bytes.
161
Some implementations may return objects which can be read
162
past this length, but this is not guaranteed.
164
raise NotImplementedError
166
def get_partial_multi(self, files, pb=None):
167
"""Put a set of files or strings into the location.
169
Requesting multiple portions of the same file can be dangerous.
171
:param files: A list of tuples of relpath, portion
172
[(path1, portion1), (path2, portion2),...]
173
:param pb: An optional ProgressBar for indicating percent done.
174
:return: A generator of file-like objects.
176
self._iterate_over(files, self.get_partial, pb, 'get_partial', expand=True)
178
152
def get_multi(self, relpaths, pb=None):
179
153
"""Get a list of file-like objects, one for each entry in relpaths.
192
166
yield self.get(relpath)
169
def get_partial(self, relpath, start, length=None):
170
"""Get just part of a file.
172
:param relpath: Path to the file, relative to base
173
:param start: The starting position to read from
174
:param length: The length to read. A length of None indicates
175
read to the end of the file.
176
:return: A file-like object containing at least the specified bytes.
177
Some implementations may return objects which can be read
178
past this length, but this is not guaranteed.
180
raise NotImplementedError
182
def get_partial_multi(self, offsets, pb=None):
183
"""Put a set of files or strings into the location.
185
Requesting multiple portions of the same file can be dangerous.
187
:param offsets: A list of tuples of relpath, start, length
188
[(path1, start1, length1),
189
(path2, start2, length2),
190
(path3, start3), ...]
191
length is optional, defaulting to None
192
:param pb: An optional ProgressBar for indicating percent done.
193
:return: A generator of file-like objects.
195
total = self._get_total(offsets)
197
for offset in offsets:
198
self._update_pb(pb, 'get_partial', count, total)
199
yield self.get_partial(*offset)
195
202
def put(self, relpath, f):
196
203
"""Copy the file-like or string object into the location.