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 |
|---|---|---|---|
| 62 | Method | __init__ | Load a config stored in the given file for the given application. |
| 96 | Method | get_config_dir | Config directory name accessor |
| 104 | Method | get_filename | Config filename accessor |
| 112 | Method | set_filename | Config filename setter |
| 147 | Method | get_option | Fetch the option value stored in the given section, at the |
| 166 | Method | set_option | Store an option value under key id at the given section. |
| 184 | Method | del_option | Remove the option identified by key under the specified |
| 201 | Method | write | save the config in a text file (handled by ConfigObj) |
| 221 | Method | rename_section | Rename a section of the config |
| 240 | Method | get_section | Fetch a section from the config |
| 253 | 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 | as_dict | Helper method to convert the Config instance to a dictionary |
| Parameters | config_file | the config filename to read (type: string or None. None implies to use CONFIG_DIR/CONFIG_FILE ) |
| Raises | ConfigError | when the config file contains format error |
| Returns | the current config directory absolute path (type: string ) | |
| Returns | the config filename from which the config has been read (type: string ) | |
Config filename setter
Updates _config_dir and _filename private attributes| Parameters | filename | full path to the config file (type: string ) |
| Parameters | key | the option key to look for (type: string ) |
| section | the section name to search in (type: string ) | |
| default | the default value to use if the option is not found (type: object ) | |
| Returns | value of given option in given section (type: object ) | |
Store an option value under key id at the given section.
@param key: the option key to look for
@type key: string
@param value: the value to store under given key
@type value: object
@param section: the section name to search in
@type section: string
@raises L{SectionNotFound} when the given section is not existing
Remove the option identified by key under the specified
section.
@param key: the option key to look for
@type key: string
@param section: the section name to search in
@type section: string
@raises L{SectionNotFound} when the given section is not existing
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.| Parameters | old_name | the section to rename (type: string ) |
| new_name | the new section name (type: string ) |
| Parameters | section_name | the section name to look for (type: string ) |
| default | the default value to use if the section is not found (type: object ) | |
| Returns | the ConfigObj section identified by section_name
(type: elisa.extern.configobj.ConfigObj or empty dict
) | |
| Parameters | section_name | the section name to update (type: string ) |
| section | the section data (type: dict ) | |
| doc | documentation of section's options (type: dict ) |