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:
parent
05c75e8c8d
commit
2465e1ce6a
@ -48,11 +48,11 @@ class GmailMaildirFolder(MaildirFolder):
|
|||||||
sorted(statusfolder.getmessageuidlist()):
|
sorted(statusfolder.getmessageuidlist()):
|
||||||
return True
|
return True
|
||||||
# check for flag changes, it's quick on a Maildir
|
# 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):
|
if message['flags'] != statusfolder.getmessageflags(uid):
|
||||||
return True
|
return True
|
||||||
# check for newer mtimes. it is also fast
|
# 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):
|
if message['mtime'] > statusfolder.getmessagemtime(uid):
|
||||||
return True
|
return True
|
||||||
return False #Nope, nothing changed
|
return False #Nope, nothing changed
|
||||||
@ -70,7 +70,7 @@ class GmailMaildirFolder(MaildirFolder):
|
|||||||
|
|
||||||
# Get mtimes
|
# Get mtimes
|
||||||
if self.synclabels:
|
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'])
|
filepath = os.path.join(self.getfullname(), msg['filename'])
|
||||||
msg['mtime'] = int(os.stat(filepath).st_mtime)
|
msg['mtime'] = int(os.stat(filepath).st_mtime)
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ class MaildirFolder(BaseFolder):
|
|||||||
sorted(statusfolder.getmessageuidlist()):
|
sorted(statusfolder.getmessageuidlist()):
|
||||||
return True
|
return True
|
||||||
# Also check for flag changes, it's quick on a Maildir.
|
# 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):
|
if message['flags'] != statusfolder.getmessageflags(uid):
|
||||||
return True
|
return True
|
||||||
return False # Nope, nothing changed.
|
return False # Nope, nothing changed.
|
||||||
@ -495,7 +495,7 @@ class MaildirFolder(BaseFolder):
|
|||||||
"""
|
"""
|
||||||
oldfmd5 = md5(self.name).hexdigest()
|
oldfmd5 = md5(self.name).hexdigest()
|
||||||
msglist = self._scanfolder()
|
msglist = self._scanfolder()
|
||||||
for mkey, mvalue in msglist.iteritems():
|
for mkey, mvalue in msglist.items():
|
||||||
filename = os.path.join(self.getfullname(), mvalue['filename'])
|
filename = os.path.join(self.getfullname(), mvalue['filename'])
|
||||||
match = re.search("FMD5=([a-fA-F0-9]+)", filename)
|
match = re.search("FMD5=([a-fA-F0-9]+)", filename)
|
||||||
if match is None:
|
if match is None:
|
||||||
|
@ -77,7 +77,7 @@ class MappedIMAPFolder(IMAPFolder):
|
|||||||
if dolock: self.maplock.acquire()
|
if dolock: self.maplock.acquire()
|
||||||
try:
|
try:
|
||||||
file = open(mapfilename + ".tmp", 'wt')
|
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.write("%d:%d\n"% (key, value))
|
||||||
file.close()
|
file.close()
|
||||||
os.rename(mapfilename + '.tmp', mapfilename)
|
os.rename(mapfilename + '.tmp', mapfilename)
|
||||||
@ -162,7 +162,7 @@ class MappedIMAPFolder(IMAPFolder):
|
|||||||
localhash = self._mb.getmessagelist()
|
localhash = self._mb.getmessagelist()
|
||||||
self.maplock.acquire()
|
self.maplock.acquire()
|
||||||
try:
|
try:
|
||||||
for key, value in localhash.items():
|
for key, value in list(localhash.items()):
|
||||||
try:
|
try:
|
||||||
key = self.l2r[key]
|
key = self.l2r[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -291,7 +291,7 @@ class OfflineImap:
|
|||||||
d = collections.defaultdict(lambda: 0)
|
d = collections.defaultdict(lambda: 0)
|
||||||
for v in l:
|
for v in l:
|
||||||
d[tuple(v)] += 1
|
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 = []
|
stack_displays = []
|
||||||
for threadId, stack in sys._current_frames().items():
|
for threadId, stack in sys._current_frames().items():
|
||||||
|
@ -190,7 +190,7 @@ class BaseRepository(CustomConfig.ConfigHelperMixin, object):
|
|||||||
dst_repo.getsep(), src_repo.getsep())] = folder
|
dst_repo.getsep(), src_repo.getsep())] = folder
|
||||||
|
|
||||||
# Find and create new folders on src_repo.
|
# 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.
|
# Don't create on dst_repo, if it is readonly.
|
||||||
if not dst_repo.get_create_folders():
|
if not dst_repo.get_create_folders():
|
||||||
break
|
break
|
||||||
@ -207,7 +207,7 @@ class BaseRepository(CustomConfig.ConfigHelperMixin, object):
|
|||||||
status_repo.makefolder(src_name_t.replace(dst_repo.getsep(),
|
status_repo.makefolder(src_name_t.replace(dst_repo.getsep(),
|
||||||
status_repo.getsep()))
|
status_repo.getsep()))
|
||||||
# Find and create new folders on dst_repo.
|
# 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():
|
if not src_repo.get_create_folders():
|
||||||
# Don't create missing folder on readonly repo.
|
# Don't create missing folder on readonly repo.
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user