The config module

The config module Managing of configuration files
The config module is a powerful interface that manages text configuration files. The files are arranged in named sections and the data is stored in key=value pairs belonging to each section. [section1_name] <key1>=<value1> <key2>=<value2> <key3>=<value3> .... [section2_name] <key1>=<value1> .... Keys and values are plain text strings - newlines in values are encoded using a simple hexadecimal notation. The config files can be also edited by using any text editor. The config module works on config files loaded in memory. For this reason, you must first open a config file by $config.open() - if the file exists on disk, its contents are loaded and you can access the data stored in it, otherwise an empty config file is created in memory. The config file is opened in read-write mode by default. You can also choose the "read-only" method - a read-only config file is never flushed to disk (but you can still set values in memory!). It is not a good idea to keep a config file open forever. A better approach is to keep settings in memory variables - when you want to write to disk, open the config file, write all your values and then close the file. You can obviously keep the config file open for some time but remember that no changes are written to the disk until config.flush or config.close is called. You write entries by using config.write and read them by using $config.read(). You can change the "current" config section by using config.setsection. The following lists all commands and functions exported by this module: $config.open $config.read $config.section $config.hassection $config.sectionlist $config.keylist $config.filelist $config.filename $config.id $config.readonly config.close config.flush config.clear config.clearsection config.setsection config.write

Index, Modules