[pypy-svn] r51303 - pypy/branch/ghop-ropes-classes/pypy/rlib
vinogradov at codespeak.net
vinogradov at codespeak.net
Tue Feb 5 20:13:51 CET 2008
Author: vinogradov
Date: Tue Feb 5 20:13:50 2008
New Revision: 51303
Modified:
pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py
Log:
Implement basic string search
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 Tue Feb 5 20:13:50 2008
@@ -49,6 +49,13 @@
return self.__class__(rope.getslice(self._node, start, stop, step))
raise NotImplementedError("Index type not known.")
+ def find(self, sub):
+ if isinstance(sub, str):
+ data = RopeString(sub)
+ if isinstance(sub, unicode):
+ data = RopeUnicode(sub)
+
+ return rope.find(self._node, data._node)
class RopeStringIterator(object):
def __init__(self, node):
@@ -102,9 +109,6 @@
def getchar(self,index):
return self._node.getchar(index)
- def find(self, sub):
- return -1
-
class RopeUnicodeIterator(object):
def __init__(self, node):
self._iter = rope.ItemIterator(node)
More information about the Pypy-commit
mailing list