Author: Amaury Forgeot d'Arc <amaur...@gmail.com>
Branch: py3k
Changeset: r48215:6b5837b87cdf
Date: 2011-10-18 12:01 +0200
http://bitbucket.org/pypy/pypy/changeset/6b5837b87cdf/

Log:    Fixes for applevel interactive code

diff --git a/lib_pypy/_pypy_interact.py b/lib_pypy/_pypy_interact.py
--- a/lib_pypy/_pypy_interact.py
+++ b/lib_pypy/_pypy_interact.py
@@ -18,9 +18,9 @@
             some_topic(),)
         while len(text) >= 80:
             i = text[:80].rfind(' ')
-            print text[:i]
+            print(text[:i])
             text = text[i+1:]
-        print text
+        print(text)
     except ImportError:
         pass
     #
diff --git a/lib_pypy/_pypy_irc_topic.py b/lib_pypy/_pypy_irc_topic.py
--- a/lib_pypy/_pypy_irc_topic.py
+++ b/lib_pypy/_pypy_irc_topic.py
@@ -181,7 +181,25 @@
 clcl vf n enpr orgjrra gur vaqhfgel gelvat gb ohvyq znpuvarf jvgu zber naq 
zber erfbheprf, naq gur clcl qrirybcref gelvat gb rng nyy bs gurz. Fb sne, gur 
jvaare vf fgvyy hapyrne
 """
 
+from string import ascii_uppercase, ascii_lowercase
+ 
+def rot13(data):
+    """ A simple rot-13 encoder since `str.encode('rot13')` was removed from
+        Python as of version 3.0.  It rotates both uppercase and lowercase 
letters individually.
+    """
+    total = []
+    for char in data:
+        if char in ascii_uppercase:
+            index = (ascii_uppercase.find(char) + 13) % 26
+            total.append(ascii_uppercase[index])
+        elif char in ascii_lowercase:
+            index = (ascii_lowercase.find(char) + 13) % 26
+            total.append(ascii_lowercase[index])
+        else:
+            total.append(char)
+    return "".join(total)
+ 
 def some_topic():
     import time
     lines = __doc__.splitlines()
-    return lines[int(time.time()) % len(lines)].decode('rot13')
+    return rot13(lines[int(time.time()) % len(lines)])
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to