Using nametrans

Daniel Shahaf d.s at daniel.shahaf.name
Sun Jan 15 17:08:44 GMT 2012


Thanks for the mail; I never fully grokked the new reverse-nametrans
stuff (and I think my config somehow works despite not having it).  One
tweak, below:

On Sun, Jan 15, 2012, at 16:18, Chris Dennis wrote:
> -----------------------------------------------------------------------
> [Repository LocalIMAP]
> type = IMAP
> remotehost = localhost
> ...
> nametrans = lambda foldername: re.sub ('^Junk E-mail$', 'Spam',
>                                 re.sub ('^Deleted Items$', 'Trash',
>                                 foldername))

Another option:

  lambda f: {'Junk E-Mail': 'Spam', 'Deleted Items': 'Trash'}.get(f, f)

http://docs.python.org/library/stdtypes.html#dict.get

> 
> [Repository RemoteIMAP]
> type = IMAP
> remotehost = isp.example.com
> ...
> nametrans = lambda foldername: re.sub ('^Spam$', 'Junk E-mail',
>                                 re.sub ('^Trash$', 'Deleted Items',
>                                 foldername))
> -----------------------------------------------------------------------




More information about the OfflineIMAP-project mailing list