/head: changeset 122

Optimized folder/IMAP.py addmessagesflags() with new listjoin() in
imaputil. Now, send the server 1:5,7 instead of 1,2,3,4,5,7.
This commit is contained in:
jgoerzen 2002-07-16 02:46:21 +01:00
parent 289412c435
commit 09cf911d53
3 changed files with 40 additions and 1 deletions

View File

@ -3,6 +3,8 @@ offlineimap (3.0.1) unstable; urgency=low
* Detabified the source.
* Added UI list to the manpage.
* Added -o (run only once) option with patch sent in by Martijn Pieters.
* Optimized folder/IMAP.py addmessagesflags() with new listjoin() in
imaputil. Now, send the server 1:5,7 instead of 1,2,3,4,5,7.
-- John Goerzen <jgoerzen@complete.org> Fri, 12 Jul 2002 07:28:24 -0500

View File

@ -66,6 +66,8 @@ class IMAPFolder(BaseFolder):
return
# Now, get the flags and UIDs for these.
# We could conceivably get rid of maxmsgid and just say
# '1:*' here.
response = imapobj.fetch('1:%d' % maxmsgid, '(FLAGS UID)')[1]
finally:
self.imapserver.releaseconnection(imapobj)
@ -146,7 +148,7 @@ class IMAPFolder(BaseFolder):
try:
imapobj.select(self.getfullname())
r = imapobj.uid('store',
','.join([str(uid) for uid in uidlist]),
imaputil.listjoin(uidlist),
'+FLAGS',
imaputil.flagsmaildir2imap(flags))
assert r[0] == 'OK', 'Error with store: ' + r[1]

View File

@ -102,3 +102,38 @@ def flagsmaildir2imap(list):
retval.sort()
return '(' + ' '.join(retval) + ')'
def listjoin(list):
start = None
end = None
retval = []
def getlist(start, end):
if start == end:
return(str(start))
else:
return(str(start) + ":" + str(end))
for item in list:
if start == None:
# First item.
start = item
end = item
elif item == end + 1:
# An addition to the list.
end = item
else:
# Here on: starting a new list.
retval.append(getlist(start, end))
start = item
end = item
if start != None:
retval.append(getlist(start, end))
return ",".join(retval)