syncing custom IMAP flags
Dan Christensen
jdc at uwo.ca
Sun Dec 5 18:23:08 GMT 2010
Nicolas Sebrecht <nicolas.s-dev at laposte.net> writes:
> This looks pretty sensible at a first glance but I need more than
> discussions.
Unfortunately I don't know enough about the overall structure of
offlineimap to implement my proposals.
>> In any case, could the attached clean-up patch be applied now? It will
>> certainly be part of any more advanced handling of custom flags, so
>> if it gets merged now then it won't be lost.
>
> Could you please send the patch inlined?
I used an inline attachment last time, which is shown inline by my
mailreader and won't be folded or altered in transmission. Do you want
it simply included as plain text in the body of the message? Like
below?
Dan
--- imaputil.py.orig 2008-03-02 18:58:51.000000000 -0500
+++ imaputil.py 2009-11-25 20:43:28.000000000 -0500
@@ -147,30 +147,26 @@
debug("imapsplit() returning:", retval)
return retval
+flagmap = [('\\Seen', 'S'),
+ ('\\Answered', 'R'),
+ ('\\Flagged', 'F'),
+ ('\\Deleted', 'T'),
+ ('\\Draft', 'D')]
+
def flagsimap2maildir(flagstring):
- flagmap = {'\\seen': 'S',
- '\\answered': 'R',
- '\\flagged': 'F',
- '\\deleted': 'T',
- '\\draft': 'D'}
retval = []
imapflaglist = [x.lower() for x in flagstring[1:-1].split()]
- for imapflag in imapflaglist:
- if flagmap.has_key(imapflag):
- retval.append(flagmap[imapflag])
+ for imapflag, maildirflag in flagmap:
+ if imapflag.lower() in imapflaglist:
+ retval.append(maildirflag)
retval.sort()
return retval
-def flagsmaildir2imap(list):
- flagmap = {'S': '\\Seen',
- 'R': '\\Answered',
- 'F': '\\Flagged',
- 'T': '\\Deleted',
- 'D': '\\Draft'}
+def flagsmaildir2imap(maildirflaglist):
retval = []
- for mdflag in list:
- if flagmap.has_key(mdflag):
- retval.append(flagmap[mdflag])
+ for imapflag, maildirflag in flagmap:
+ if maildirflag in maildirflaglist:
+ retval.append(imapflag)
retval.sort()
return '(' + ' '.join(retval) + ')'
More information about the OfflineIMAP-project
mailing list