Package Biskit :: Module SettingsManager :: Class SettingsManager
[hide private]
[frames] | no frames]

Class SettingsManager

source code

SettingsManager merges the parameters from a default and a user configuration file into a python module where they are published as normal fields. The general flow is like this:
 default.cfg ---[SettingsParser]---                                         [SettingsManager]--->[settings]
                                          /
           user.cfg---[SettingsParser]---/

See P.SettingsParser See B.settings

The default configurations should be located in:

* biskit/external/defaults/settings.cfg --> B.settings * biskit/external/defaults/settings_Mod.cfg --> B.Mod.settings * biskit/external/defaults/settings_Dock.cfg --> B.Dock.settings

The user configurations are expected in files of the same name in ~/.biskit/.

Instance Methods [hide private]
  __init__(self, fdefault, fuser, createmissing=False, verbose=1)
{'str':SettingsParser.Setting} __update(self, cfg_default, cfg_user)
Override default settings by valid (or equally invalid) user settings.
  collectSettings(self)
Parse and combine default and user-defined config files.
  writeUserSettings(self, errorsonly=False)
Create a settings file with all options that are invalid with their default value.
{str : any} settings2dict(self)
Create dictionary from settings.
  updateNamespace(self, ns)
Parse in default configuration and user configuration file

Class Variables [hide private]
  USER_HEADER = """ ## This is a Biskit user configuration file. The...

Instance Variables [hide private]
  settings
will hold extracted Setting's

Method Details [hide private]

__init__(self, fdefault, fuser, createmissing=False, verbose=1)
(Constructor)

source code 
Parameters:
  • fdefault - default configuration file
  • fuser (str) - user configuration file
  • createmissing (bool) - create user config file if missing
  • verbose (1|0) - verbosity level (default: 1)

__update(self, cfg_default, cfg_user)

source code 

Override default settings by valid (or equally invalid) user settings.
Parameters:
  • cfg_default ({'str':SettingsParser.Setting}) - settings read in from default file
  • cfg_user ({'str':SettingsParser.Setting}) - settings read in from user config file
Returns: {'str':SettingsParser.Setting}
configuration with valid user settings overriding default ones

collectSettings(self)

source code 

Parse and combine default and user-defined config files.

writeUserSettings(self, errorsonly=False)

source code 

Create a settings file with all options that are invalid with their default value.

settings2dict(self)

source code 

Create dictionary from settings.
Returns: {str : any}
dictionary of parameter names (keys) and values

updateNamespace(self, ns)

source code 

  • Parse in default configuration and user configuration file
  • Merge the two, preferring valid user settings
  • Create missing user configuration file if createmissing=True
  • Insert parameters into the given namespace
  • Parameters:
    • ns ({str:any}) - namespace of a module ( obtained with locals() )

    Class Variable Details [hide private]

    USER_HEADER

    Value:
    """
    ##     This is a Biskit user configuration file. The parameters in
    ##     this file are overriding the default parameters given in
    ##     %(fdefault)s.
    ##     If missing, Biskit creates a new user configuration file with
    ##     those parameters for which the default value seems
    ##     invalid. The remaining parameters are commented out.
    
    ...                                                                    
          

    Instance Variable Details [hide private]

    settings


    will hold extracted Setting's