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 |
| 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 ) | |
| Parameters | key | the option key to look for (type: string ) |
| value | the value to store under given key (type: object ) | |
| section | the section name to search in (type: string ) | |
| Raises | SectionNotFound | when the given section does not exist |
| Parameters | key | the option key to look for (type: string ) |
| section | the section name to search in (type: string ) | |
| Raises | SectionNotFound | when the given section does not exist |
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 ) |