home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / UserList.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  6.4 KB  |  178 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''A more or less complete user-defined wrapper around list objects.'''
  5. import collections
  6.  
  7. class UserList(collections.MutableSequence):
  8.     
  9.     def __init__(self, initlist = None):
  10.         self.data = []
  11.         if initlist is not None:
  12.             if type(initlist) == type(self.data):
  13.                 self.data[:] = initlist
  14.             elif isinstance(initlist, UserList):
  15.                 self.data[:] = initlist.data[:]
  16.             else:
  17.                 self.data = list(initlist)
  18.         
  19.  
  20.     
  21.     def __repr__(self):
  22.         return repr(self.data)
  23.  
  24.     
  25.     def __lt__(self, other):
  26.         return self.data < self._UserList__cast(other)
  27.  
  28.     
  29.     def __le__(self, other):
  30.         return self.data <= self._UserList__cast(other)
  31.  
  32.     
  33.     def __eq__(self, other):
  34.         return self.data == self._UserList__cast(other)
  35.  
  36.     
  37.     def __ne__(self, other):
  38.         return self.data != self._UserList__cast(other)
  39.  
  40.     
  41.     def __gt__(self, other):
  42.         return self.data > self._UserList__cast(other)
  43.  
  44.     
  45.     def __ge__(self, other):
  46.         return self.data >= self._UserList__cast(other)
  47.  
  48.     
  49.     def __cast(self, other):
  50.         if isinstance(other, UserList):
  51.             return other.data
  52.         return other
  53.  
  54.     
  55.     def __cmp__(self, other):
  56.         return cmp(self.data, self._UserList__cast(other))
  57.  
  58.     __hash__ = None
  59.     
  60.     def __contains__(self, item):
  61.         return item in self.data
  62.  
  63.     
  64.     def __len__(self):
  65.         return len(self.data)
  66.  
  67.     
  68.     def __getitem__(self, i):
  69.         return self.data[i]
  70.  
  71.     
  72.     def __setitem__(self, i, item):
  73.         self.data[i] = item
  74.  
  75.     
  76.     def __delitem__(self, i):
  77.         del self.data[i]
  78.  
  79.     
  80.     def __getslice__(self, i, j):
  81.         i = max(i, 0)
  82.         j = max(j, 0)
  83.         return self.__class__(self.data[i:j])
  84.  
  85.     
  86.     def __setslice__(self, i, j, other):
  87.         i = max(i, 0)
  88.         j = max(j, 0)
  89.         if isinstance(other, UserList):
  90.             self.data[i:j] = other.data
  91.         elif isinstance(other, type(self.data)):
  92.             self.data[i:j] = other
  93.         else:
  94.             self.data[i:j] = list(other)
  95.  
  96.     
  97.     def __delslice__(self, i, j):
  98.         i = max(i, 0)
  99.         j = max(j, 0)
  100.         del self.data[i:j]
  101.  
  102.     
  103.     def __add__(self, other):
  104.         if isinstance(other, UserList):
  105.             return self.__class__(self.data + other.data)
  106.         if isinstance(other, type(self.data)):
  107.             return self.__class__(self.data + other)
  108.         return self.__class__(self.data + list(other))
  109.  
  110.     
  111.     def __radd__(self, other):
  112.         if isinstance(other, UserList):
  113.             return self.__class__(other.data + self.data)
  114.         if isinstance(other, type(self.data)):
  115.             return self.__class__(other + self.data)
  116.         return self.__class__(list(other) + self.data)
  117.  
  118.     
  119.     def __iadd__(self, other):
  120.         if isinstance(other, UserList):
  121.             self.data += other.data
  122.         elif isinstance(other, type(self.data)):
  123.             self.data += other
  124.         else:
  125.             self.data += list(other)
  126.         return self
  127.  
  128.     
  129.     def __mul__(self, n):
  130.         return self.__class__(self.data * n)
  131.  
  132.     __rmul__ = __mul__
  133.     
  134.     def __imul__(self, n):
  135.         self.data *= n
  136.         return self
  137.  
  138.     
  139.     def append(self, item):
  140.         self.data.append(item)
  141.  
  142.     
  143.     def insert(self, i, item):
  144.         self.data.insert(i, item)
  145.  
  146.     
  147.     def pop(self, i = -1):
  148.         return self.data.pop(i)
  149.  
  150.     
  151.     def remove(self, item):
  152.         self.data.remove(item)
  153.  
  154.     
  155.     def count(self, item):
  156.         return self.data.count(item)
  157.  
  158.     
  159.     def index(self, item, *args):
  160.         return self.data.index(item, *args)
  161.  
  162.     
  163.     def reverse(self):
  164.         self.data.reverse()
  165.  
  166.     
  167.     def sort(self, *args, **kwds):
  168.         self.data.sort(*args, **kwds)
  169.  
  170.     
  171.     def extend(self, other):
  172.         if isinstance(other, UserList):
  173.             self.data.extend(other.data)
  174.         else:
  175.             self.data.extend(other)
  176.  
  177.  
  178.