Sync -> Mails there. Sync -> mails gone

Matthias Beyer mail at beyermatthias.de
Thu Jan 29 12:32:22 GMT 2015


As already posted to this ML, my code is outsourced of the
offlineimaprc file into an extra python file. This is the code:

    import re
    import time

    def hfu_local_folderfilter(name):
        return name.startswith("hfu.")

    #
    # Translate the local folder name to the remote folder name:
    #
    #   hfu.INBOX   -> INBOX
    #   hfu.foo     -> INBOX.foo
    #
    def hfu_nametrans_local_to_remote(name):
        if (name == "hfu.INBOX"):
            ret = "INBOX"
        else:
            ret = "INBOX." + re.sub('^hfu\.', '', name)
        print("Translated local->remote: '" + name + "' to '" + ret + "'")
        return ret

    #
    # Translate the remote folder name to the local folder name:
    #
    #   INBOX   -> hfu.INBOX
    #   foo     -> hfu.foo
    #
    def hfu_nametrans_remote_to_local(name):
        ret = "hfu." + re.sub('^INBOX\.', '', name)
        print("Translated remote->local: '" + name + "' to '" + ret + "'")
        return ret


The name conversion looks good I guess. What I don't get: I have the
filter applied, but the *_nametrans_* functions still get the other
folders passed, ... they are not filtered out...


On 29-01-2015 13:28:33, Tomasz Żok wrote:
> On 2015-01-29 at 12:35, Matthias Beyer wrote:
> > On 29-01-2015 12:13:11, Tomasz Żok wrote:
> > >
> > > 2.  Change LocalFoo's nametrans into:
> > >         lambda foldername = if foldername == 'localPREFIX.INBOX' then 'INBOX' else 'INBOX.' + re.sub('^localPREFIX\.', '', foldername)
> > >
> 
> Oh, sorry... I should have never posted without testing my own snippets.
> 
> The correct way to do it in Python would be:
>     lambda foldername: 'INBOX' if foldername == 'localPREFIX.INBOX' else 'INBOX.' + re.sub('^localPREFIX\.', '', foldername)
> 
> 
> I tested it this time:
> 
> In [1]: import re
> 
> In [2]: x = lambda foldername: 'INBOX' if foldername == 'localPREFIX.INBOX' else 'INBOX.' + re.sub('^localPREFIX\.', '', foldername)
> 
> In [3]: x('localPREFIX.INBOX')
> Out[3]: 'INBOX'
> 
> In [4]: x('localPREFIX.Example')
> Out[4]: 'INBOX.Example'
> 
> 
> Can you try it now?
> Regards,
> Tomasz

-- 
Mit freundlichen Grüßen,
Kind regards,
Matthias Beyer

Proudly sent with mutt.
Happily signed with gnupg.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/offlineimap-project/attachments/20150129/aa4229b2/attachment-0003.sig>


More information about the OfflineIMAP-project mailing list