ยปCore Development>Code coverage>Lib/UserList.py

Python code coverage for Lib/UserList.py

#countcontent
11"""A more or less complete user-defined wrapper around list objects."""
2n/a
31import collections
4n/a
52class UserList(collections.MutableSequence):
61 def __init__(self, initlist=None):
7900 self.data = []
8900 if initlist is not None:
9n/a # XXX should this accept an arbitrary sequence?
10872 if type(initlist) == type(self.data):
11702 self.data[:] = initlist
12170 elif isinstance(initlist, UserList):
137 self.data[:] = initlist.data[:]
14n/a else:
15163 self.data = list(initlist)
1616 def __repr__(self): return repr(self.data)
171 def __lt__(self, other): return self.data < self.__cast(other)
181 def __le__(self, other): return self.data <= self.__cast(other)
19818 def __eq__(self, other): return self.data == self.__cast(other)
203 def __ne__(self, other): return self.data != self.__cast(other)
211 def __gt__(self, other): return self.data > self.__cast(other)
221 def __ge__(self, other): return self.data >= self.__cast(other)
231 def __cast(self, other):
24819 if isinstance(other, UserList): return other.data
25405 else: return other
261 def __cmp__(self, other):
271 return cmp(self.data, self.__cast(other))
281 __hash__ = None # Mutable sequence, so not hashable
2911 def __contains__(self, item): return item in self.data
301400 def __len__(self): return len(self.data)
319193 def __getitem__(self, i): return self.data[i]
3230 def __setitem__(self, i, item): self.data[i] = item
3313 def __delitem__(self, i): del self.data[i]
341 def __getslice__(self, i, j):
35247 i = max(i, 0); j = max(j, 0)
36247 return self.__class__(self.data[i:j])
371 def __setslice__(self, i, j, other):
38137 i = max(i, 0); j = max(j, 0)
39137 if isinstance(other, UserList):
4067 self.data[i:j] = other.data
4170 elif isinstance(other, type(self.data)):
4267 self.data[i:j] = other
43n/a else:
443 self.data[i:j] = list(other)
451 def __delslice__(self, i, j):
4614 i = max(i, 0); j = max(j, 0)
4714 del self.data[i:j]
481 def __add__(self, other):
4917 if isinstance(other, UserList):
5014 return self.__class__(self.data + other.data)
513 elif isinstance(other, type(self.data)):
522 return self.__class__(self.data + other)
53n/a else:
541 return self.__class__(self.data + list(other))
551 def __radd__(self, other):
563 if isinstance(other, UserList):
571 return self.__class__(other.data + self.data)
582 elif isinstance(other, type(self.data)):
591 return self.__class__(other + self.data)
60n/a else:
611 return self.__class__(list(other) + self.data)
621 def __iadd__(self, other):
637 if isinstance(other, UserList):
644 self.data += other.data
653 elif isinstance(other, type(self.data)):
661 self.data += other
67n/a else:
682 self.data += list(other)
696 return self
701 def __mul__(self, n):
7153 return self.__class__(self.data*n)
721 __rmul__ = __mul__
731 def __imul__(self, n):
743 self.data *= n
753 return self
7643 def append(self, item): self.data.append(item)
771007 def insert(self, i, item): self.data.insert(i, item)
786 def pop(self, i=-1): return self.data.pop(i)
7911 def remove(self, item): self.data.remove(item)
806 def count(self, item): return self.data.count(item)
8124 def index(self, item, *args): return self.data.index(item, *args)
823 def reverse(self): self.data.reverse()
8310 def sort(self, *args, **kwds): self.data.sort(*args, **kwds)
841 def extend(self, other):
856 if isinstance(other, UserList):
863 self.data.extend(other.data)
87n/a else:
883 self.data.extend(other)