Class e.c.c.Config(log.Loggable):

Part of elisa.core.config View In Hierarchy

Configuration system

Each configuration is stored in a text file. The configuration is structured in sections. Each section stores a set of options. Example:

 [section_name]
 some_list = ['some','list']
 some_string = 'foobar'
 some_int = 1
Line # Kind Name Docs
60 Method __init__ Load a config stored in the given file for the given application.
94 Method get_config_dir Config directory name accessor
102 Method get_filename Config filename accessor
110 Method set_filename Config filename setter
145 Method get_option Fetch the option value stored in the given section, at the
164 Method set_option Store an option value under key id at the given section.
182 Method del_option Remove the option identified by key under the specified
199 Method write save the config in a text file (handled by ConfigObj)
219 Method rename_section Rename a section of the config
238 Method get_section Fetch a section from the config
251 Method set_section Store section_data in a new section identified by section_name
277 Method del_section Remove the section identified by section_name
286 Method delete_file Delete the configuration file on disk.
297 Method as_dict Helper method to convert the Config instance to a dictionary
122 Method _create_config Undocumented
def __init__(self, config_file=None, default_config=''):
Load a config stored in the given file for the given application.
Parametersconfig_filethe config filename to read (type: string or None. None implies to use CONFIG_DIR/CONFIG_FILE )
RaisesConfigErrorwhen the config file contains format error
def get_config_dir(self):
Config directory name accessor
Returnsthe current config directory absolute path (type: string )
def get_filename(self):
Config filename accessor
Returnsthe config filename from which the config has been read (type: string )
def set_filename(self, filename):
Config filename setter

Updates _config_dir and _filename private attributes

Parametersfilenamefull path to the config file (type: string )
def _create_config(self, config_file, default_config):
Undocumented
def get_option(self, key, section='general', default=None):
Fetch the option value stored in the given section, at the given key. Return a default value if the key is not found.
Parameterskeythe option key to look for (type: string )
sectionthe section name to search in (type: string )
defaultthe default value to use if the option is not found (type: object )
Returnsvalue of given option in given section (type: object )
def set_option(self, key, value, section='general'):
Store an option value under key id at the given section.
Parameterskeythe option key to look for (type: string )
valuethe value to store under given key (type: object )
sectionthe section name to search in (type: string )
RaisesSectionNotFoundwhen the given section does not exist
def del_option(self, key, section='general'):
Remove the option identified by key under the specified section.
Parameterskeythe option key to look for (type: string )
sectionthe section name to search in (type: string )
RaisesSectionNotFoundwhen the given section does not exist
def write(self, filename=None):
save the config in a text file (handled by ConfigObj)
def rename_section(self, old_name, new_name):
Rename a section of the config

Options and comments stored in the section are kept intact. The config is update in-place. No result is returned by this method.

Parametersold_namethe section to rename (type: string )
new_namethe new section name (type: string )
def get_section(self, section_name, default=None):
Fetch a section from the config
Parameterssection_namethe section name to look for (type: string )
defaultthe default value to use if the section is not found (type: object )
Returnsthe ConfigObj section identified by section_name (type: elisa.extern.configobj.ConfigObj or empty dict )
def set_section(self, section_name, section={}, doc={}):
Store section_data in a new section identified by section_name in the config
Parameterssection_namethe section name to update (type: string )
sectionthe section data (type: dict )
docdocumentation of section's options (type: dict )
def del_section(self, section_name):
Remove the section identified by section_name
Parameterssection_namethe section name to delete (type: string )
def delete_file(self):
Delete the configuration file on disk.
def as_dict(self):
Helper method to convert the Config instance to a dictionary
Returnsa mapping of the config's options by section name (type: dict )
API Documentation for Elisa Media Center, generated by pydoctor at 2009-02-16 19:15:05.