[PATCH 09/15] Replace dictionary iteration methods

Nicolas Sebrecht nicolas.s-dev at laposte.net
Tue May 10 01:39:40 BST 2016


Why is this required?

On Tue, May 10, 2016 at 01:18:31AM +0200, Łukasz Żarnowiecki wrote:

> Signed-off-by: Łukasz Żarnowiecki <dolohow at outlook.com>
> ---
>  offlineimap/accounts.py                 |  2 +-
>  offlineimap/folder/Base.py              |  8 ++++----
>  offlineimap/folder/GmailMaildir.py      | 10 +++++-----
>  offlineimap/folder/LocalStatus.py       |  6 +++---
>  offlineimap/folder/LocalStatusSQLite.py | 10 +++++-----
>  offlineimap/folder/Maildir.py           |  6 +++---
>  offlineimap/folder/UIDMaps.py           | 10 +++++-----
>  offlineimap/imaplib2.py                 |  2 +-
>  offlineimap/init.py                     | 12 ++++++------
>  offlineimap/mbnames.py                  |  2 +-
>  offlineimap/repository/Base.py          |  4 ++--
>  offlineimap/repository/LocalStatus.py   |  4 ++--
>  offlineimap/utils/stacktrace.py         |  2 +-
>  test/tests/test_00_globals.py           |  2 +-
>  14 files changed, 40 insertions(+), 40 deletions(-)
> 
> diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py
> index a8e8a5e..aa97ffe 100644
> --- a/offlineimap/accounts.py
> +++ b/offlineimap/accounts.py
> @@ -483,7 +483,7 @@ def syncfolder(account, remotefolder, quick):
>                  # the UID mapped case we want the actual local UIDs, not their
>                  # remote counterparts
>                  positive_uids = filter(
> -                    lambda uid: uid > 0, partial.messagelist.keys())
> +                    lambda uid: uid > 0, list(partial.messagelist.keys()))
>                  if len(positive_uids) > 0:
>                      min_uid = min(positive_uids)
>                  else:
> diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
> index 06cf451..6243853 100644
> --- a/offlineimap/folder/Base.py
> +++ b/offlineimap/folder/Base.py
> @@ -272,7 +272,7 @@ class BaseFolder(object):
>      def ismessagelistempty(self):
>          """Is the list of messages empty."""
>  
> -        if len(self.messagelist.keys()) < 1:
> +        if len(list(self.messagelist.keys())) < 1:
>              return True
>          return False
>  
> @@ -307,7 +307,7 @@ class BaseFolder(object):
>  
>          You may have to call cachemessagelist() before calling this function!"""
>  
> -        return self.getmessagelist().keys()
> +        return list(self.getmessagelist().keys())
>  
>      def getmessagecount(self):
>          """Gets the number of messages."""
> @@ -1009,14 +1009,14 @@ class BaseFolder(object):
>                      delflaglist[flag] = []
>                  delflaglist[flag].append(uid)
>  
> -        for flag, uids in addflaglist.items():
> +        for flag, uids in list(addflaglist.items()):

Hmm, does this work as expected?

>              self.ui.addingflags(uids, flag, dstfolder)
>              if self.repository.account.dryrun:
>                  continue #don't actually add in a dryrun
>              dstfolder.addmessagesflags(uids, set(flag))
>              statusfolder.addmessagesflags(uids, set(flag))
>  
> -        for flag,uids in delflaglist.items():
> +        for flag,uids in list(delflaglist.items()):
>              self.ui.deletingflags(uids, flag, dstfolder)
>              if self.repository.account.dryrun:
>                  continue #don't actually remove in a dryrun

-- 
Nicolas Sebrecht




More information about the OfflineIMAP-project mailing list