Don't use sort() on dict values()

This won't work in python3 anymore, so just use sorted() when needed.
In one case, we could remove the sort() completely as were were sanity checking
one line above, that we only having one UID as response which makes sorting
unneeded.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2012-02-05 13:17:16 +01:00
parent b33f2452f0
commit e6e708ec78
2 changed files with 3 additions and 5 deletions

View File

@ -1,5 +1,5 @@
# IMAP folder support # IMAP folder support
# Copyright (C) 2002-2011 John Goerzen & contributors # Copyright (C) 2002-2012 John Goerzen & contributors
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -327,7 +327,6 @@ class IMAPFolder(BaseFolder):
raise ValueError("While attempting to find UID for message with " raise ValueError("While attempting to find UID for message with "
"header %s, got wrong-sized matchinguids of %s" %\ "header %s, got wrong-sized matchinguids of %s" %\
(headername, str(matchinguids))) (headername, str(matchinguids)))
matchinguids.sort()
return long(matchinguids[0]) return long(matchinguids[0])
def savemessage_fetchheaders(self, imapobj, headername, headervalue): def savemessage_fetchheaders(self, imapobj, headername, headervalue):

View File

@ -182,13 +182,12 @@ def flagsimap2maildir(flagstring):
return retval return retval
def flagsmaildir2imap(maildirflaglist): def flagsmaildir2imap(maildirflaglist):
"""Convert set of flags ([DR]) into a string '(\\Draft \\Deleted)'""" """Convert set of flags ([DR]) into a string '(\\Deleted \\Draft)'"""
retval = [] retval = []
for imapflag, maildirflag in flagmap: for imapflag, maildirflag in flagmap:
if maildirflag in maildirflaglist: if maildirflag in maildirflaglist:
retval.append(imapflag) retval.append(imapflag)
retval.sort() return '(' + ' '.join(sorted(retval)) + ')'
return '(' + ' '.join(retval) + ')'
def uid_sequence(uidlist): def uid_sequence(uidlist):
"""Collapse UID lists into shorter sequence sets """Collapse UID lists into shorter sequence sets