<DKIM> [PATCH 3/3] __syncmessagesto_flags: store keywords
Igor Almeida
igor.contato at gmail.com
Sun Nov 8 18:39:57 GMT 2015
Hi Nicolas,
Thanks for reviewing! Comments below.
On 11/07/2015 02:57 PM, Nicolas Sebrecht wrote:
> On Sat, Nov 07, 2015 at 11:16:55AM -0300, Igor Almeida wrote:
>> This uses the destination folder's keyword mapping to translate the
>> message's keywords into some appropriate format.
>>
>> Tested only with local Maildir.
>
> Please, document this in offlineimap.conf.
>
Right. I'm more interested in the internals right now, that is, if this
patch will play nicely with the rest of offlineimap (and other use
cases). For this patchset all I did was debug (and learn) my way around
the codebase to see the minimal necessary changes for my use case
(one-way IMAP -> maildir).
> Also, I wonder how Keywords for IMAP <-> IMAP is currently discarded.
>
The default getkeywordmap() raises an exception, so selfflags is not
changed. Is that what you mean?
To support IMAP -> IMAP i'd start by creating a dict-like object that
does obj[key]==key...
That would fail if the destination IMAP server refuses characters that
the source IMAP server allows, though...
>> Signed-off-by: Igor Almeida <igor.contato at gmail.com>
>> ---
>> offlineimap/folder/Base.py | 26 ++++++++++++++++++++++++++
>> 1 file changed, 26 insertions(+)
>>
>> diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
>> index 5031a40..b48afbe 100644
>> --- a/offlineimap/folder/Base.py
>> +++ b/offlineimap/folder/Base.py
>> @@ -937,6 +937,32 @@ class BaseFolder(object):
>> else:
>> statusflags = set()
>>
>> + #keywords: if there is a keyword map, use it to figure out what
>> + #other 'flags' we should add
>> + try:
>> + keywordmap = dstfolder.getrepository().getkeywordmap()
>> + knownkeywords = set(keywordmap.keys())
>> +
>> + selfkeywords = self.getmessagekeywords(uid)
>> +
>> + if not knownkeywords >= selfkeywords:
>> + #some of the message's keywords are not in the mapping, so
>> + #skip them
>> +
>> + skipped_keywords = list(selfkeywords - knownkeywords)
>> + selfkeywords &= knownkeywords
>> +
>> + self.ui.warn("Unknown keywords skipped: %s\n"
>> + "You may want to change your configuration to include "
>> + "those\n" % (skipped_keywords))
>
> I guess that dynamically allowing any Keyword would be the next topic.
> :-)
>
Hm... in that case offlineimap itself would have to edit the config
file, I don't think that's what you really want.
--
Igor Almeida
More information about the OfflineIMAP-project
mailing list