Replace dictionary iteration methods

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-16 19:48:50 +02:00 committed by Nicolas Sebrecht
parent 05c75e8c8d
commit 2465e1ce6a
5 changed files with 10 additions and 10 deletions

View File

@ -48,11 +48,11 @@ class GmailMaildirFolder(MaildirFolder):
sorted(statusfolder.getmessageuidlist()):
return True
# check for flag changes, it's quick on a Maildir
for (uid, message) in self.getmessagelist().iteritems():
for (uid, message) in self.getmessagelist().items():
if message['flags'] != statusfolder.getmessageflags(uid):
return True
# check for newer mtimes. it is also fast
for (uid, message) in self.getmessagelist().iteritems():
for (uid, message) in self.getmessagelist().items():
if message['mtime'] > statusfolder.getmessagemtime(uid):
return True
return False #Nope, nothing changed
@ -70,7 +70,7 @@ class GmailMaildirFolder(MaildirFolder):
# Get mtimes
if self.synclabels:
for uid, msg in self.messagelist.items():
for uid, msg in list(self.messagelist.items()):
filepath = os.path.join(self.getfullname(), msg['filename'])
msg['mtime'] = int(os.stat(filepath).st_mtime)

View File

@ -230,7 +230,7 @@ class MaildirFolder(BaseFolder):
sorted(statusfolder.getmessageuidlist()):
return True
# Also check for flag changes, it's quick on a Maildir.
for (uid, message) in self.getmessagelist().iteritems():
for (uid, message) in self.getmessagelist().items():
if message['flags'] != statusfolder.getmessageflags(uid):
return True
return False # Nope, nothing changed.
@ -495,7 +495,7 @@ class MaildirFolder(BaseFolder):
"""
oldfmd5 = md5(self.name).hexdigest()
msglist = self._scanfolder()
for mkey, mvalue in msglist.iteritems():
for mkey, mvalue in msglist.items():
filename = os.path.join(self.getfullname(), mvalue['filename'])
match = re.search("FMD5=([a-fA-F0-9]+)", filename)
if match is None:

View File

@ -77,7 +77,7 @@ class MappedIMAPFolder(IMAPFolder):
if dolock: self.maplock.acquire()
try:
file = open(mapfilename + ".tmp", 'wt')
for (key, value) in self.diskl2r.iteritems():
for (key, value) in self.diskl2r.items():
file.write("%d:%d\n"% (key, value))
file.close()
os.rename(mapfilename + '.tmp', mapfilename)
@ -162,7 +162,7 @@ class MappedIMAPFolder(IMAPFolder):
localhash = self._mb.getmessagelist()
self.maplock.acquire()
try:
for key, value in localhash.items():
for key, value in list(localhash.items()):
try:
key = self.l2r[key]
except KeyError:

View File

@ -291,7 +291,7 @@ class OfflineImap:
d = collections.defaultdict(lambda: 0)
for v in l:
d[tuple(v)] += 1
return list((k, v) for k, v in d.iteritems())
return list((k, v) for k, v in d.items())
stack_displays = []
for threadId, stack in sys._current_frames().items():

View File

@ -190,7 +190,7 @@ class BaseRepository(CustomConfig.ConfigHelperMixin, object):
dst_repo.getsep(), src_repo.getsep())] = folder
# Find and create new folders on src_repo.
for src_name_t, src_folder in src_hash.iteritems():
for src_name_t, src_folder in src_hash.items():
# Don't create on dst_repo, if it is readonly.
if not dst_repo.get_create_folders():
break
@ -207,7 +207,7 @@ class BaseRepository(CustomConfig.ConfigHelperMixin, object):
status_repo.makefolder(src_name_t.replace(dst_repo.getsep(),
status_repo.getsep()))
# Find and create new folders on dst_repo.
for dst_name_t, dst_folder in dst_hash.iteritems():
for dst_name_t, dst_folder in dst_hash.items():
if not src_repo.get_create_folders():
# Don't create missing folder on readonly repo.
break