[pypy-svn] r50237 - pypy/branch/ghop-ropes-classes/pypy/rlib
cfbolz at codespeak.net
cfbolz at codespeak.net
Mon Dec 31 19:05:38 CET 2007
Author: cfbolz
Date: Mon Dec 31 19:05:37 2007
New Revision: 50237
Modified:
pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py
Log:
be a bit less nonsensical about slices
Modified: pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py
==============================================================================
--- pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py (original)
+++ pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py Mon Dec 31 19:05:37 2007
@@ -32,18 +32,10 @@
if isinstance(index, int):
return self.getchar(index)
if isinstance(index, slice):
- start, stop, step = index.start, index.stop, index.step
- start = start or 0
- stop = (stop and (stop < 0 and len(self) + stop or stop)) or len(self)
- step = step or 1
+ start, stop, step = index.indices(self._node.length())
return self.__class__(rope.getslice(self._node, start, stop, step))
-
- def getchar(self,index):
- if isinstance(self, RopeString):
- return self._node.getchar(index)
- if isinstance(self, RopeUnicode):
- return self._node.getunichar(index)
raise NotImplementedError("Index type not known.")
+
class RopeStringIterator(object):
def __init__(self, node):
@@ -81,6 +73,9 @@
#Need rewrite
return RopeUnicode(rope.str_decode_ascii(self._node))
+ def getchar(self,index):
+ return self._node.getchar(index)
+
class RopeUnicodeIterator(object):
def __init__(self, node):
self._iter = rope.ItemIterator(node)
@@ -126,3 +121,6 @@
return RopeString(result)
else:
raise NotImplementedError("Do i need implement such ascii encoding?")
+
+ def getchar(self,index):
+ return self._node.getunichar(index)
More information about the Pypy-commit
mailing list