gws.lib.inifile¶
Read and write ini files.
Reads one or more ini files with configparser into a nested dict (section, then option)
or into a flat dict with section.option keys, and writes a flat dict back as ini text.
When reading, option names keep their case, files that do not exist are skipped, and values
from later files override earlier ones.
Example:
d = gws.lib.inifile.from_paths_flat('/data/a.ini', '/data/b.ini')
# {'section.option': 'value', ...}
text = gws.lib.inifile.to_string({'section.option': 'value'})
Source code: gws.lib.inifile
Package Contents¶
- gws.lib.inifile.from_paths(*paths: str) dict¶
Read ini files into a nested dict.
- Parameters:
*paths – Paths to ini files. Missing files are skipped, later files override earlier ones.
- Returns:
A dict with section names as keys and dicts of options as values.