Table Of Contents

Previous topic

base

Next topic

base.dochelpers

This content refers to the previous stable release of PyMVPA. Please visit www.pymvpa.org for the most recent version of PyMVPA and its documentation.

base.config

Module: base.config

Inheritance diagram for mvpa.base.config:

Registry-like monster

ConfigManager

class mvpa.base.config.ConfigManager(filenames=None)

Bases: ConfigParser.SafeConfigParser

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 instanciated or whenever Config.reload() is called later on. By default it looks for a config file named pymvpa.cfg in the current directory and .pymvpa.cfg in the user’s home directory. Morever, 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 section general. Some examples:

MVPA_VERBOSE=1

will become:

[general]
verbose = 1

However, MVPA_VERBOSE_OUTPUT=stdout becomes:

[verbose]
output = stdout

Any lenght 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.

Initialization reads settings from config files and env. variables.

Parameters:filenames (list of filenames) –
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 of default is returned whenever the config parser does not have the requested option and/or section.

getAsDType(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 of default 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 of default 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.