]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
String method conversion.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 9 Feb 2001 06:56:56 +0000 (06:56 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 9 Feb 2001 06:56:56 +0000 (06:56 +0000)
Lib/poplib.py

index 4e23ff96aa3f7281a28fd038e6a767d90c60d1f7..c67cbc67644f38d100adba031163c138ca090696 100644 (file)
@@ -6,16 +6,13 @@ Based on the J. Myers POP3 draft, Jan. 96
 # Author: David Ascher <david_ascher@brown.edu>
 #         [heavily stealing from nntplib.py]
 # Updated: Piers Lauder <piers@cs.su.oz.au> [Jul '97]
+# String method conversion and test jig improvements by ESR, February 2001.
 
 # Example (see the test function at the end of this file)
 
-TESTSERVER = "localhost"
-TESTACCOUNT = "test"
-TESTPASSWORD = "_passwd_"
-
 # Imports
 
-import re, socket, string
+import re, socket
 
 # Exception raised when an error or invalid response is received:
 
@@ -192,10 +189,10 @@ class POP3:
         Result is tuple of 2 ints (message count, mailbox size)
         """
         retval = self._shortcmd('STAT')
-        rets = string.split(retval)
+        rets = retval.split()
         #if self._debugging: print '*stat*', `rets`
-        numMessages = string.atoi(rets[1])
-        sizeMessages = string.atoi(rets[2])
+        numMessages = int(rets[1])
+        sizeMessages = int(rets[2])
         return (numMessages, sizeMessages)
 
 
@@ -281,7 +278,7 @@ class POP3:
             raise error_proto('-ERR APOP not supported by server')
         import md5
         digest = md5.new(m.group(1)+secret).digest()
-        digest = string.join(map(lambda x:'%02x'%ord(x), digest), '')
+        digest = ''.join(map(lambda x:'%02x'%ord(x), digest))
         return self._shortcmd('APOP %s %s' % (user, digest))
 
 
@@ -307,10 +304,11 @@ class POP3:
 
 
 if __name__ == "__main__":
-    a = POP3(TESTSERVER)
+    import sys
+    a = POP3(sys.argv[1])
     print a.getwelcome()
-    a.user(TESTACCOUNT)
-    a.pass_(TESTPASSWORD)
+    a.user(sys.argv[2])
+    a.pass_(sys.argv[3])
     a.list()
     (numMsgs, totalSize) = a.stat()
     for i in range(1, numMsgs + 1):