Reading and writing INI format files
This module provides an enhanced INI format reader and writer based on the standard library’s configparser .
- class clldutils.inifile.INI(defaults=None, dict_type=<class 'dict'>, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section='DEFAULT', interpolation=<object object>, converters=<object object>)[source]
An enhanced ConfigParser with better support for list-valued options and multiline text.
- set(section, option, value=None)[source]
Enhances ConfigParser.set by
ignoring None values
creating missing sections
accepting list instances as value
- gettext(section, option, whitespace_preserving_prefix='.')[source]
While configparser supports multiline values, it does this at the expense of stripping leading whitespace for each line in such a value. Sometimes we want to preserve such whitespace, e.g. to be able to put markdown with nested lists into INI files. We support this be introducing a special prefix, which is prepended to lines starting with whitespace in
INI.settext()
and stripped inINI.gettext()
.