mvpa2.base.ConfigManager¶
-
class
mvpa2.base.
ConfigManager
(filenames=None)¶ Central configuration registry for PyMVPA.
The purpose of this class is to collect all configurable settings used by various parts of PyMVPA. It is fairly simple and does only little more than the standard Python ConfigParser. Like ConfigParser it is blind to the data that it stores, i.e. not type checking is performed.
Configuration files (INI syntax) in multiple location are passed when the class is instantiated or whenever
Config.reload()
is called later on. By default it looks for a config file namedpymvpa2.cfg
in the current directory andpymvpa2.cfg
in the user’s home directory. Moreover, the constructor takes an optional argument with a list of additional file names to parse.In addition to configuration files, this class also looks for special environment variables to read settings from. Names of such variables have to start with
MVPA_
following by the an optional section name and the variable name itself (‘_’ as delimiter). If no section name is provided, the variables will be associated with sectiongeneral
. Some examples:MVPA_VERBOSE=1
will become:
[general] verbose = 1
However,
MVPA_VERBOSE_OUTPUT=stdout
becomes:[verbose] output = stdout
Any length of variable name as allowed, e.g. MVPA_SEC1_LONG_VARIABLE_NAME=1 becomes:
[sec1] long variable name = 1
Settings from custom configuration files (specified by the constructor argument) have the highest priority and override settings found in the current directory. They in turn override user-specific settings and finally the content of any
MVPA_*
environment variables overrides all settings read from any file.Methods
Initialization reads settings from config files and env. variables.
Parameters: filenames : list of filenames Methods
-
get
(section, option, default=None, **kwargs)¶ Wrapper around SafeConfigParser.get() with a custom default value.
This method simply wraps the base class method, but adds a
default
keyword argument. The value ofdefault
is returned whenever the config parser does not have the requested option and/or section.
-
get_as_dtype
(section, option, dtype, default=None)¶ Convenience method to query options with a custom default and type
This method simply wraps the base class method, but adds a
default
keyword argument. The value ofdefault
is returned whenever the config parser does not have the requested option and/or section.In addition, the returned value is converted into the specified
dtype
.
-
getboolean
(section, option, default=None)¶ Wrapper around SafeConfigParser.getboolean() with a custom default.
This method simply wraps the base class method, but adds a
default
keyword argument. The value ofdefault
is returned whenever the config parser does not have the requested option and/or section.
-
reload
()¶ Re-read settings from all configured locations.
-
save
(filename)¶ Write current configuration to a file.
-