summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2001-02-09 06:56:56 (GMT)
committerEric S. Raymond <esr@thyrsus.com>2001-02-09 06:56:56 (GMT)
commit341f929f51bef3d57d09e51ebc29cd83264cdd26 (patch)
tree4487b56376769f10d831660d918f502529b08acd /Lib
parent25a0cbc7961545cf0989a63555a20dac1201ff76 (diff)
downloadcpython-341f929f51bef3d57d09e51ebc29cd83264cdd26.zip
cpython-341f929f51bef3d57d09e51ebc29cd83264cdd26.tar.gz
cpython-341f929f51bef3d57d09e51ebc29cd83264cdd26.tar.bz2
String method conversion.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/poplib.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/Lib/poplib.py b/Lib/poplib.py
index 4e23ff9..c67cbc6 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -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):