Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
return self.headers | return self.headers | ||||
def geturl(self): | def geturl(self): | ||||
return self._url | return self._url | ||||
def read(self, amt=None): | def read(self, amt=None): | ||||
# the _rbuf test is only in this first if for speed. It's not | # the _rbuf test is only in this first if for speed. It's not | ||||
# logically necessary | # logically necessary | ||||
if self._rbuf and not amt is None: | if self._rbuf and amt is not None: | ||||
L = len(self._rbuf) | L = len(self._rbuf) | ||||
if amt > L: | if amt > L: | ||||
amt -= L | amt -= L | ||||
else: | else: | ||||
s = self._rbuf[:amt] | s = self._rbuf[:amt] | ||||
self._rbuf = self._rbuf[amt:] | self._rbuf = self._rbuf[amt:] | ||||
return s | return s | ||||
self._data = data | self._data = data | ||||
self._lgt = len(data) // indexsize | self._lgt = len(data) // indexsize | ||||
self._extra = [] | self._extra = [] | ||||
def _calculate_index(self, i): | def _calculate_index(self, i): | ||||
return i * indexsize | return i * indexsize | ||||
def __delitem__(self, i): | def __delitem__(self, i): | ||||
if not isinstance(i, slice) or not i.stop == -1 or not i.step is None: | if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: | ||||
raise ValueError("deleting slices only supports a:-1 with step 1") | raise ValueError("deleting slices only supports a:-1 with step 1") | ||||
i = self._fix_index(i.start) | i = self._fix_index(i.start) | ||||
if i < self._lgt: | if i < self._lgt: | ||||
self._data = self._data[:i * indexsize] | self._data = self._data[:i * indexsize] | ||||
self._lgt = i | self._lgt = i | ||||
self._extra = [] | self._extra = [] | ||||
else: | else: | ||||
self._extra = self._extra[:i - self._lgt] | self._extra = self._extra[:i - self._lgt] | ||||
self._offsets[count] = off | self._offsets[count] = off | ||||
count += 1 | count += 1 | ||||
off += indexsize + s | off += indexsize + s | ||||
if off != len(self._data): | if off != len(self._data): | ||||
raise ValueError("corrupted data") | raise ValueError("corrupted data") | ||||
return count | return count | ||||
def __delitem__(self, i): | def __delitem__(self, i): | ||||
if not isinstance(i, slice) or not i.stop == -1 or not i.step is None: | if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: | ||||
raise ValueError("deleting slices only supports a:-1 with step 1") | raise ValueError("deleting slices only supports a:-1 with step 1") | ||||
i = self._fix_index(i.start) | i = self._fix_index(i.start) | ||||
if i < self._lgt: | if i < self._lgt: | ||||
self._offsets = self._offsets[:i] | self._offsets = self._offsets[:i] | ||||
self._lgt = i | self._lgt = i | ||||
self._extra = [] | self._extra = [] | ||||
else: | else: | ||||
self._extra = self._extra[:i - self._lgt] | self._extra = self._extra[:i - self._lgt] |