Prettify and use new uidexists() helper function

Make the folder classes use uidexists() more. Add some code
documentation while going through.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-05-07 11:11:20 +02:00 committed by Nicolas Sebrecht
parent 0318c6ad34
commit f4081985dc
2 changed files with 10 additions and 2 deletions

View File

@ -562,7 +562,7 @@ class IMAPFolder(BaseFolder):
def deletemessages_noconvert(self, uidlist):
# Weed out ones not in self.messagelist
uidlist = [uid for uid in uidlist if uid in self.messagelist]
uidlist = [uid for uid in uidlist if self.uidexists(uid)]
if not len(uidlist):
return

View File

@ -295,8 +295,16 @@ class MaildirFolder(BaseFolder):
assert final_dir != tmpdir
def deletemessage(self, uid):
if not uid in self.messagelist:
"""Unlinks a message file from the Maildir.
:param uid: UID of a mail message
:type uid: String
:return: Nothing, or an Exception if UID but no corresponding file
found.
"""
if not self.uidexists(uid):
return
filename = self.messagelist[uid]['filename']
try:
os.unlink(filename)