upgrade to Jython 2.5.0

This commit is contained in:
Dmitry Jemerov
2009-07-30 19:38:38 +04:00
parent f221494a43
commit bb24ece14b
487 changed files with 155647 additions and 18427 deletions
+4 -13
View File
@@ -1,6 +1,5 @@
"""A more or less complete user-defined wrapper around list objects."""
#Imported from Python 2.3.5 and added _fixindex
class UserList:
def __init__(self, initlist=None):
self.data = []
@@ -30,10 +29,10 @@ class UserList:
def __setitem__(self, i, item): self.data[i] = item
def __delitem__(self, i): del self.data[i]
def __getslice__(self, i, j):
i = self._fixindex(i); j = self._fixindex(j)
i = max(i, 0); j = max(j, 0)
return self.__class__(self.data[i:j])
def __setslice__(self, i, j, other):
i = self._fixindex(i); j = self._fixindex(j)
i = max(i, 0); j = max(j, 0)
if isinstance(other, UserList):
self.data[i:j] = other.data
elif isinstance(other, type(self.data)):
@@ -41,7 +40,7 @@ class UserList:
else:
self.data[i:j] = list(other)
def __delslice__(self, i, j):
i = self._fixindex(i); j = self._fixindex(j)
i = max(i, 0); j = max(j, 0)
del self.data[i:j]
def __add__(self, other):
if isinstance(other, UserList):
@@ -78,17 +77,9 @@ class UserList:
def count(self, item): return self.data.count(item)
def index(self, item, *args): return self.data.index(item, *args)
def reverse(self): self.data.reverse()
def sort(self, *args): self.data.sort(*args)
def sort(self, *args, **kwds): self.data.sort(*args, **kwds)
def extend(self, other):
if isinstance(other, UserList):
self.data.extend(other.data)
else:
self.data.extend(other)
def _fixindex(self, index):
if index < 0:
index += len(self.data)
elif index > len(self.data):
index = len(self.data)
index = max(index, 0)
return index