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
add_section
(section)Create a new section in the configuration. defaults
()get
(section, option[, default])Wrapper around SafeConfigParser.get() with a custom default value. get_as_dtype
(section, option, dtype[, default])Convenience method to query options with a custom default and type getboolean
(section, option[, default])Wrapper around SafeConfigParser.getboolean() with a custom default. getfloat
(section, option)getint
(section, option)has_option
(section, option)Check for the existence of a given option in a given section. has_section
(section)Indicate whether the named section is present in the configuration. items
(section[, raw, vars])Return a list of tuples with (name, value) for each option in the section. options
(section)Return a list of option names for the given section name. optionxform
(optionstr)read
(filenames)Read and parse a filename or a list of filenames. readfp
(fp[, filename])Like read() but the argument must be a file-like object. reload
()Re-read settings from all configured locations. remove_option
(section, option)Remove an option. remove_section
(section)Remove a file section. save
(filename)Write current configuration to a file. sections
()Return a list of section names, excluding [DEFAULT] set
(section, option[, value])Set an option. write
(fp)Write an .ini-format representation of the configuration state. Initialization reads settings from config files and env. variables.
Parameters: filenames : list of filenames Methods
add_section
(section)Create a new section in the configuration. defaults
()get
(section, option[, default])Wrapper around SafeConfigParser.get() with a custom default value. get_as_dtype
(section, option, dtype[, default])Convenience method to query options with a custom default and type getboolean
(section, option[, default])Wrapper around SafeConfigParser.getboolean() with a custom default. getfloat
(section, option)getint
(section, option)has_option
(section, option)Check for the existence of a given option in a given section. has_section
(section)Indicate whether the named section is present in the configuration. items
(section[, raw, vars])Return a list of tuples with (name, value) for each option in the section. options
(section)Return a list of option names for the given section name. optionxform
(optionstr)read
(filenames)Read and parse a filename or a list of filenames. readfp
(fp[, filename])Like read() but the argument must be a file-like object. reload
()Re-read settings from all configured locations. remove_option
(section, option)Remove an option. remove_section
(section)Remove a file section. save
(filename)Write current configuration to a file. sections
()Return a list of section names, excluding [DEFAULT] set
(section, option[, value])Set an option. write
(fp)Write an .ini-format representation of the configuration state. -
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.
-