<DKIM> offlineimap configuration file and variables
heavytull at hotmail.com
Fri Jan 20 00:33:07 GMT 2017
On Thu, 19 Jan, 2017, 23:13:56 +0100, Nicolas Sebrecht wrote:
> On Thu, Jan 19, 2017 at 09:35:11PM +0000, Jethro Tull wrote:
> > On Wed, 18 Jan, 2017, 17:58:59 +0100, Nicolas Sebrecht wrote:
> > > On Wed, Jan 18, 2017 at 12:38:36AM +0000, Jethro Tull wrote:
> > > > I have written a script for folderfilter and nametrans which I load in the
> > > > [general] section like this:
> > > >
> > > > [general]
> > > > ...
> > > > pythonfile = ~/my_script.py
> > > >
> > > > It contains a function that takes as argument a list containing all folders and
> > > > their corresponding local names. I would like to define the list, say,
> > > > "gmail_list", in the offlineimap config file, which is what I tried but it
> > > > doesn't seem to work. offlineimap complains like this " global name
> > > > 'gmail_list' is not defined". While "gmail_list" is defined in the [general]
> > > > section. I even tried defining it in [Repository gmaillocal] and [Repository
> > > > gmailremote]. The result is always the same.
> > >
> > > Please, share both the pythonfile and the folderfilter configuration
> > > line.
> > why not sharing the python file, though my question was simply about whether
> > variables could be defined directly into offlineimap config file for use in
> > functions loaded through the "pythonfile = ..." option. How does offlineimap
> > parse its config file?
> Ok. I get what you want, now. I think I've read your mail too fast.
> You might have better luck by defining the variables in the
> [DEFAULT] section. Never tried, though.
> my_list = ['a', 'b']
> offlineimap_option_eval = python_function( %(my_list)s )
> Parsing is done by the ConfigParser library, not offlineimap itself. See
> Notice that the pythonfile can do whatever python can. So, it's possible
> to load the offlineimap's configuration file from the pythonfile and
> parse it from there. I agree this would be ugly.
> However, since the list is likely "static" I see no reason to put the
> definitions of the lists in the offlineimap configuration file instead
> of the pythonfile (or any other file).
> Nicolas Sebrecht
I tried as you suggested defining my list in the [DEFAULT] section, the result
is same as previously, it does not work. I'm trying to put my list in the
offlineimap config file because I want to configure everything at only one
place. I will investigate the possibility of setting all the configuration from
a pythonfile, this might be the only solution. This might even be more powerful
as this will be a pure python script.
More information about the OfflineIMAP-project