Show More
@@ -44,17 +44,16 class BaseIndexObject(object): | |||||
44 | def append(self, tup): |
|
44 | def append(self, tup): | |
45 | self._extra.append(tup) |
|
45 | self._extra.append(tup) | |
46 |
|
46 | |||
47 |
def _ |
|
47 | def _check_index(self, i): | |
48 | if not isinstance(i, int): |
|
48 | if not isinstance(i, int): | |
49 | raise TypeError("expecting int indexes") |
|
49 | raise TypeError("expecting int indexes") | |
50 | if i < 0 or i >= len(self): |
|
50 | if i < 0 or i >= len(self): | |
51 | raise IndexError |
|
51 | raise IndexError | |
52 | return i |
|
|||
53 |
|
52 | |||
54 | def __getitem__(self, i): |
|
53 | def __getitem__(self, i): | |
55 | if i == -1: |
|
54 | if i == -1: | |
56 | return (0, 0, 0, -1, -1, -1, -1, nullid) |
|
55 | return (0, 0, 0, -1, -1, -1, -1, nullid) | |
57 |
|
|
56 | self._check_index(i) | |
58 | if i >= self._lgt: |
|
57 | if i >= self._lgt: | |
59 | return self._extra[i - self._lgt] |
|
58 | return self._extra[i - self._lgt] | |
60 | index = self._calculate_index(i) |
|
59 | index = self._calculate_index(i) | |
@@ -79,7 +78,8 class IndexObject(BaseIndexObject): | |||||
79 | def __delitem__(self, i): |
|
78 | def __delitem__(self, i): | |
80 | if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: |
|
79 | if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: | |
81 | raise ValueError("deleting slices only supports a:-1 with step 1") |
|
80 | raise ValueError("deleting slices only supports a:-1 with step 1") | |
82 |
i = |
|
81 | i = i.start | |
|
82 | self._check_index(i) | |||
83 | if i < self._lgt: |
|
83 | if i < self._lgt: | |
84 | self._data = self._data[:i * indexsize] |
|
84 | self._data = self._data[:i * indexsize] | |
85 | self._lgt = i |
|
85 | self._lgt = i | |
@@ -113,7 +113,8 class InlinedIndexObject(BaseIndexObject | |||||
113 | def __delitem__(self, i): |
|
113 | def __delitem__(self, i): | |
114 | if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: |
|
114 | if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: | |
115 | raise ValueError("deleting slices only supports a:-1 with step 1") |
|
115 | raise ValueError("deleting slices only supports a:-1 with step 1") | |
116 |
i = |
|
116 | i = i.start | |
|
117 | self._check_index(i) | |||
117 | if i < self._lgt: |
|
118 | if i < self._lgt: | |
118 | self._offsets = self._offsets[:i] |
|
119 | self._offsets = self._offsets[:i] | |
119 | self._lgt = i |
|
120 | self._lgt = i |
General Comments 0
You need to be logged in to leave comments.
Login now