syspolicy :: config :: Config :: Class Config
[hide private]
[frames] | no frames]

Class Config

source code

Known Subclasses:

Instance Methods [hide private]
 
__init__(self, name, source=None, load=True)
Initialize the Config class and load the configuration if `load` is True
source code
 
attributes(self, section='_default_')
This function returns a list of attributes in section `section`.
source code
 
clear(self)
This function clears the data of this Config
source code
 
compare_to(self, other_config)
This function compares this Config element to another.
source code
 
get(self, path=[])
This function is a short form for get_branch
source code
 
get_branch(self, path=[])
This function returns a configuration tree branch at `path`.
source code
 
load(self, configfile=None)
Function that loads the configuration from `configfile` using YAML.
source code
 
print_all(self)
This function dumps the configuration data to the console for debugging purposes.
source code
 
save(self, configfile=None)
Function that saves the configuration to `configfile` using YAML.
source code
 
sections(self)
This function returns a list of sections present in the configuration.
source code
 
set(self, path, value)
This function sets a configuration attribute at `path` to `value`.
source code
Class Variables [hide private]
  data = None
the data dictionary tree
  name = None
the identifier name for this Config
  source = None
the source configuration file
Method Details [hide private]

__init__(self, name, source=None, load=True)
(Constructor)

source code 

Initialize the Config class and load the configuration if `load` is True

Parameters:
  • name - The identifier name for the Config
  • source - Source file name where to load/save the configuration
  • load - Whether to load the configuration at start (default: True)

attributes(self, section='_default_')

source code 

This function returns a list of attributes in section `section`.

Parameters:
  • section - The section which's attributes are to be listed
Returns:
The list of attributes in `section`

compare_to(self, other_config)

source code 

This function compares this Config element to another.

Parameters:
  • other_config - An other Config (or it's subclass) element
Returns:
A dictionary tree of differences

get(self, path=[])

source code 

This function is a short form for get_branch

Parameters:
  • path - The location of the branch to be returned
Returns:
Configuration branch at `path` or None.

get_branch(self, path=[])

source code 

This function returns a configuration tree branch at `path`.

Parameters:
  • path - The location of the branch to be returned
Returns:
Configuration branch at `path` or None.

load(self, configfile=None)

source code 

Function that loads the configuration from `configfile` using YAML. The configuration is stored in self.data as a dictionary tree.

Parameters:
  • configfile - the file name from which to load the configuration
Returns:
True if configuration was loaded, False otherwise

print_all(self)

source code 

This function dumps the configuration data to the console for debugging purposes. The data is formatted using YAML.

save(self, configfile=None)

source code 

Function that saves the configuration to `configfile` using YAML.

Parameters:
  • configfile - the file name in which to save the configuration
Returns:
True if configuration was saved, False otherwise

set(self, path, value)

source code 

This function sets a configuration attribute at `path` to `value`.

Parameters:
  • path - The path to the attribute that is to be set to `value`
  • value - The new value for the attribute at `path`
Returns:
True if the operation was successful