Package Ganga :: Package Utility :: Package Config :: Module Config :: Class PackageConfig
[hide private]
[frames] | no frames]

Class PackageConfig

source code

Package Config object represents a Configuration Unit (typically related to Ganga Packages). It should not be created directly but only via the getConfig method.

PackageConfig has a name which corresponds to the [name] section in the .gangarc file. Once initialized the configuration may only be modified by special setUserValues methods. This will give a chance to Ganga to take further actions such as automatic update of the .gangarc file.

The PackageConfig interface is designed for Ganga Package Developers. User oriented interface is available via the GPI.

meta keywords:

Instance Methods [hide private]
 
__init__(self, name, docstring, **meta)
Arguments:
source code
 
_addOpenOption(self, name, value) source code
 
__iter__(self)
Iterate over the effective options.
source code
 
__getitem__(self, o)
Get the effective value of option o.
source code
 
addOption(self, name, default_value, docstring, override=False, **meta) source code
 
setSessionValue(self, name, value, raw=0)
Add or override options as a part of second phase of initialization of this configuration module (PHASE 2) If the default type of the option is not string, then the expression will be evaluated.
source code
 
setUserValue(self, name, value)
Modify option at runtime.
source code
 
overrideDefaultValue(self, name, val) source code
 
revertToSession(self, name) source code
 
revertToDefault(self, name) source code
 
revertToSessionOptions(self) source code
 
revertToDefaultOptions(self) source code
 
getEffectiveOptions(self) source code
 
getEffectiveOption(self, name) source code
 
getEffectiveLevel(self, name)
Return 0 if option is effectively set at the user level, 1 if at session level or 2 if at default level
source code
 
attachUserHandler(self, pre, post)
Attach a user handler: - pre(name,x) will be always called before setUserValue(name,x) - post(name,x2) will be always called after setUserValue(name,x)
source code
 
attachSessionHandler(self, pre, post)
See attachUserHandler().
source code
 
deleteUndefinedOptions(self) source code
Method Details [hide private]

__init__(self, name, docstring, **meta)
(Constructor)

source code 

Arguments:

  • name may not contain blanks and should be a valid python identifier otherwise ValueError is raised
  • temporary name migration conversion applies -- see _migrate_name() meta args have the same meaning as for the ConfigOption:
    • hidden
    • cfile

setSessionValue(self, name, value, raw=0)

source code 

Add or override options as a part of second phase of initialization of this configuration module (PHASE 2) If the default type of the option is not string, then the expression will be evaluated. Optional argument raw indicates if special treatment of PATH-like variables is disabled (enabled by default). The special treatment applies to the session level values only (and not the default one!).

setUserValue(self, name, value)

source code 

Modify option at runtime. This method corresponds to the user action so the value of the option is considered 'modified' If the default type of the option is not string, then the expression will be evaluated.

attachUserHandler(self, pre, post)

source code 
Attach a user handler:
- pre(name,x) will be always called before setUserValue(name,x)
- post(name,x2) will be always called after setUserValue(name,x)

pre() acts as a filter for the value of the option: its return value (x2) will be set
Before setting the value will be evaluated (unless a default value type is a string)
post() will get x2 as the option value.

It is OK to give None for pre or post. For example:
   config.attachUserHandler(None,post) attaches only the post handler.