Change filter with lambda to list comprehension

It is more readable and returns a list therefore it is compatible both
with Python 2 and 3.

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Łukasz Żarnowiecki
2016-05-08 16:55:13 +02:00
committed by Nicolas Sebrecht
parent 068ac7c410
commit 19c43308b9
5 changed files with 11 additions and 17 deletions

View File

@ -858,8 +858,7 @@ class BaseFolder(object):
threads = []
copylist = filter(lambda uid: not statusfolder.uidexists(uid),
self.getmessageuidlist())
copylist = [uid for uid in self.getmessageuidlist() if not statusfolder.uidexists(uid)]
num_to_copy = len(copylist)
if num_to_copy and self.repository.account.dryrun:
self.ui.info("[DRYRUN] Copy {0} messages from {1}[{2}] to {3}".format(
@ -909,10 +908,10 @@ class BaseFolder(object):
# The list of messages to delete. If sync of deletions is disabled we
# still remove stale entries from statusfolder (neither in local nor
# remote).
deletelist = filter(
lambda uid: uid >= 0 and not self.uidexists(uid)
and (self._sync_deletes or not dstfolder.uidexists(uid)),
statusfolder.getmessageuidlist())
deletelist = [uid for uid in statusfolder.getmessageuidlist()
if uid >= 0 and
not self.uidexists(uid) and
(self._sync_deletes or not dstfolder.uidexists(uid))]
if len(deletelist):
# Delete in statusfolder first to play safe. In case of abort, we
@ -921,7 +920,7 @@ class BaseFolder(object):
# user, or not being tracked (e.g. because of maxage).
statusfolder.deletemessages(deletelist)
# Filter out untracked messages
deletelist = filter(lambda uid: dstfolder.uidexists(uid), deletelist)
deletelist = [uid for uid in deletelist if dstfolder.uidexists(uid)]
if len(deletelist):
self.ui.deletingmessages(deletelist, [dstfolder])
if self.repository.account.dryrun:

View File

@ -204,7 +204,7 @@ class MaildirFolder(BaseFolder):
retval[uid]['filename'] = filepath
if min_date != None:
# Re-include messages with high enough uid's.
positive_uids = filter(lambda uid: uid > 0, retval)
positive_uids = [uid for uid in retval if uid > 0]
if positive_uids:
min_uid = min(positive_uids)
for uid in date_excludees.keys():