Methods format_section() get_section_names() read() write() write_section()
|
Description
A class for reading and writing "ini" style files.
-
Method format_section
string module.Config.format_section(string section, mapping attributes)
-
Method read
mapping module.Config.read(string contents)
- Description
converts an ini-file string into a mapping of section names
to section configuration contents.
a section name must be unique within a given file, however
a section may contain multiple entries with the same key. in
such a situation, the key will point to an array containing the
values in the order in which they were encountered in the
configuration file.
- Parameter contents
a string containing the contents of an ini file.
-
Method write
string module.Config.write(mapping config, array|void order)
- Description
formats a configuration mapping, such as one produced by read,
into the ini file format.
- Parameter config
the configuration mapping
- Parameter order
an optional array containing section names in the order in which
they should be added to the resulting string.
- Returns
a string in the ini file format.
-
Method get_section_names
array module.Config.get_section_names(string contents)
- Description
get a list of configuration sections from an ini formatted string
- Parameter contents
a string containing an ini-formatted string
-
Method write_section
int module.Config.write_section(string file, string section, mapping attributes)
- Description
writes a section to a configuration file, replacing the corresponding
section, if it exists. makes a backup of the old file before writing
the new file. note that this method will remove any existing comments
or formatting from the file on disk.
- Parameter file
the name of the file to read/write
- Parameter section
the name of the section to write
- Parameter attributes
the section of configuration to write.
|