/head: changeset 20

Fixed several bugs in imaplib, particularly with regard to read()
This commit is contained in:
jgoerzen 2002-06-20 15:09:19 +01:00
parent 036b3d10b6
commit 9eff85dd0c
4 changed files with 17 additions and 6 deletions

View File

@ -54,6 +54,7 @@ class IMAPFolder(BaseFolder):
return self.messagelist
def getmessage(self, uid):
print "***************** GETMESSAGE %d" % uid
assert(self.imapobj.select(self.getfullname())[0] == 'OK')
return self.imapobj.uid('fetch', '%d' % uid, '(RFC822)')[1][0][1]

View File

@ -76,14 +76,14 @@ class MaildirFolder(BaseFolder):
nouidcounter -= 1
else:
uid = long(uidmatch.group(1))
flagmatch = re.search(':.*2,([A-Z]+)')
flagmatch = re.search(':.*2,([A-Z]+)', messagename)
flags = []
if flagmatch:
flags = [f for x in flagmatch.group(1)]
flags = [x for x in flagmatch.group(1)]
flags.sort()
self.messagelist[uid] = {'uid': uid,
'flags': flags,
'filename': messagename}
'filename': file}
def getmessagelist(self):
return self.messagelist

View File

@ -222,8 +222,10 @@ class IMAP4:
def read(self, size):
"""Read 'size' bytes from remote."""
return self.file.read(size)
retval = ''
while len(retval) < size:
retval += self.file.read(size - len(retval))
return retval
def readline(self):
"""Read line from remote."""
@ -858,6 +860,7 @@ class IMAP4:
if self.debug >= 4:
self._mesg('read literal size %s' % size)
data = self.read(size)
print "Got data size %d" % len(data)
# Store response with literal as tuple
@ -1056,7 +1059,10 @@ class IMAP4_SSL(IMAP4):
def read(self, size):
"""Read 'size' bytes from remote."""
return self.sslobj.read(size)
retval = ''
while len(retval) < size:
retval += self.sslobj.read(size - len(retval))
return retval
def readline(self):

View File

@ -32,6 +32,7 @@ class IMAPServer:
self.port = 993
else:
self.port = 143
self.imapobj = None
def getdelim(self):
"""Returns this server's folder delimiter. Can only be called
@ -47,6 +48,8 @@ class IMAPServer:
"""Opens a connection to the server and returns an appropriate
object."""
if self.imapobj != None:
return self.imapobj
imapobj = None
if self.usessl:
imapobj = imaplib.IMAP4_SSL(self.hostname, self.port)
@ -61,6 +64,7 @@ class IMAPServer:
self.delim = imaputil.dequote(self.delim)
self.root = imaputil.dequote(self.root)
self.imapobj = imapobj
return imapobj