Re: using more than one nametrans in offlineimaprc
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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 ....
|
|