Complete.Org: Mailing Lists: Archives: offlineimap: June 2009:
Re: using more than one nametrans in offlineimaprc
Home

Re: using more than one nametrans in offlineimaprc

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: James Smith <metal.lunchbox@xxxxxxxxx>
Cc: offlineimap@xxxxxxxxxxxx
Subject: Re: using more than one nametrans in offlineimaprc
From: sssslang <sssslang@xxxxxxxxx>
Date: Wed, 3 Jun 2009 16:22:42 +0800

2009/6/2 James Smith <metal.lunchbox@xxxxxxxxx>
> I'm using offlineimap with gmail and mutt and am very satisfied. It just
> works, and most importantly it does something that I couldn't really find
> anything else to do reliably. Thanks. My question is this. Gmail gives
> their
> folders some stupid names, "[Gmail]/Sent Mail" and "[Gmail]/Drafts". Using
> nametrans in offlinimaprc I want to make those "Sent" and "Drafts". I'm not
> very familiar with python and I'm not a real expert with regex. This is
> what
> I have in offlinimaprc:
> nametrans = lambda foldername:
> re.sub('^\[Gmail\]/Drafts','Drafts',foldername)
> nametrans = lambda foldername: re.sub('^\[Gmail\]/Sent\
> Mail','Sent',foldername)
> The problem is that the second "nametrans =" statement simply overrides the
> first so that the drafts folder stays as it is. How do I combine these two
> into one statement? thanks
> james
>
>
>
offlineimaprc has a option: "pythonfile", which will be imported to the
current workspace. so you can write you own nametrans functions instead of
the "simple lambda". the function need a string as argument and returns a
translated name.

here's a simple example:

def folder_nametrans(fname):
    if name == 'foo':
        return one_name
    elif name == 'bar':
        return another_name
    else ....




[Prev in Thread] Current Thread [Next in Thread]