/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:
parent
289412c435
commit
09cf911d53
@ -3,6 +3,8 @@ offlineimap (3.0.1) unstable; urgency=low
|
|||||||
* Detabified the source.
|
* Detabified the source.
|
||||||
* Added UI list to the manpage.
|
* Added UI list to the manpage.
|
||||||
* Added -o (run only once) option with patch sent in by Martijn Pieters.
|
* 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
|
-- John Goerzen <jgoerzen@complete.org> Fri, 12 Jul 2002 07:28:24 -0500
|
||||||
|
|
||||||
|
@ -66,6 +66,8 @@ class IMAPFolder(BaseFolder):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Now, get the flags and UIDs for these.
|
# 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]
|
response = imapobj.fetch('1:%d' % maxmsgid, '(FLAGS UID)')[1]
|
||||||
finally:
|
finally:
|
||||||
self.imapserver.releaseconnection(imapobj)
|
self.imapserver.releaseconnection(imapobj)
|
||||||
@ -146,7 +148,7 @@ class IMAPFolder(BaseFolder):
|
|||||||
try:
|
try:
|
||||||
imapobj.select(self.getfullname())
|
imapobj.select(self.getfullname())
|
||||||
r = imapobj.uid('store',
|
r = imapobj.uid('store',
|
||||||
','.join([str(uid) for uid in uidlist]),
|
imaputil.listjoin(uidlist),
|
||||||
'+FLAGS',
|
'+FLAGS',
|
||||||
imaputil.flagsmaildir2imap(flags))
|
imaputil.flagsmaildir2imap(flags))
|
||||||
assert r[0] == 'OK', 'Error with store: ' + r[1]
|
assert r[0] == 'OK', 'Error with store: ' + r[1]
|
||||||
|
@ -102,3 +102,38 @@ def flagsmaildir2imap(list):
|
|||||||
retval.sort()
|
retval.sort()
|
||||||
return '(' + ' '.join(retval) + ')'
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user