nametrans and lambda function
Jethro Tull
heavytull at hotmail.com
Fri Jan 20 21:15:16 GMT 2017
offlineimap v. 7.0.8
I'm using a function, "pathsubs()", loaded through a pythonfile for nametrans.
This function will return the local folder name to be synced with the given
remote folder through the variable folder_r. For debugging purpose this
variable is set by default to the only remote folder I'm interested in.
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 )
For these settings offlineimap does not work properly and says:
ERROR: While attempting to sync account 'gmail'
descriptor 'lower' requires a 'str' object but received a 'NoneType'
*** Finished account 'gmail' in 0:08
ERROR: Exceptions occurred during the run!
ERROR: While attempting to sync account 'gmail'
descriptor 'lower' requires a 'str' object but received a 'NoneType'
It should be noted that pathsubs() will return without any value if folder_r is
set wrongly. As the error says a 'NoneType' was received it might be that
folder_r was indeed wrongly set.
If I do not specify any parameter to pathsubs offlineimap works well as
expected. Here are the corresponding settings:
folderfilter = lambda foldername: foldername in [ '[Gmail]/Sent Mail' ]
nametrans = lambda folder: pathsubs()
In the pythonfile pathsubs is set with folder_r = '[Gmail]/Sent Mail' and the
local folder to be synced with is set as 'sent'. The variable localfolders in the
offlineimap config file is set to '~/gmail'. Working as expected means that
offlineimap does indeed sync only '[Gmail]/Sent Mail' with '~/gmail/sent' which
means both folderfilter and nametrans worked fine.
More information about the OfflineIMAP-project
mailing list