<DKIM> nametrans and lambda function
Jethro Tull
heavytull at hotmail.com
Mon Jan 23 23:30:03 GMT 2017
On Sat, 21 Jan, 2017, 19:11:34 -0800, Andrej Rode wrote:
> > > > Here are the key settings about the problem from my offlineimap
> > > > configuration: folderfilter = lambda foldername: foldername in [
> > > > '[Gmail]/Sent Mail' ] nametrans = lambda folder: pathsubs( folder_r =
> > > > folder )
> > >
> > > nametrans = pathsubs(folder)
> > are you sure this is a possibility?? I had tried it previously, it was so
> > worse ...
> [...]
> > That's really strange, don't you have a working example of nametrans?
>
> With latest offlineimap this works:
>
> nametrans = lambda folder: re.sub('!', '.', folder[1:])
>
> Instead of doing re.sub I could also call some other random function in my
> namespace. So your first configuration should work as well. Maybe you have an
> error in your pathsubs somewhere?
>
> Cheers, Andrej
>
I finally solved my problem with nametrans. It's indeed related to my function
pathsubs. It uses a list in which I stored the remote folders with their
corresponding local names and would return a NoneType if the string passed as
argument was not in that list since for this case a lonely "return" statement
was put.
As I was thinking nametrans would be invoked only for folders selected by
folderfilter I didn't care about this lonely "return" statement. But it seems
offlineimap uses nametrans statically with folderfilter in an expression
parsing all folder names found on the server. And as my list does not contain
all folders from the server but only the ones I'm interested in, this whould
necessarily make my function return a NoneType at some point, making offlineimap
crashing.
More information about the OfflineIMAP-project
mailing list