[pypy-svn] r50039 - pypy/branch/ghop-ropes-classes/pypy/rlib

vinogradov at codespeak.net vinogradov at codespeak.net
Sun Dec 23 12:36:51 CET 2007


Author: vinogradov
Date: Sun Dec 23 12:36:50 2007
New Revision: 50039

Modified:
   pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py
Log:
Implement methods of RopeUnicode to pass construction test

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	Sun Dec 23 12:36:50 2007
@@ -27,4 +27,16 @@
         return self * n
 
 class RopeUnicode(object):
-    pass
+    def __init__ (self, s):
+        if isinstance (s, str):
+            s = unicode(s)
+        self._node = rope.LiteralUnicodeNode(unicode(s))
+    
+    def __len__ (self):
+        return self._node.length()
+    
+    def __getitem__ (self, index):
+        return self._node.getunichar(index)
+    
+    def __eq__ (self, other):
+        return rope.eq (self._node, rope.LiteralUnicodeNode(other))



More information about the Pypy-commit mailing list