Inireader provides a simple API to handle ini style files.
Added tag 0.2.0 for changeset 413d4f600190
retire the `sortdict`, now useless since py3 (from 3.6) dicts are insert order sorted

clone

read-only
https://hg.sr.ht/~pythonian/inireader
read/write
ssh://hg@hg.sr.ht/~pythonian/inireader

#Inireader

Inireader provides a simple API to handle ini style files.

#Basic example

Example file myapp.cfg:

hello = World

[db]
uri = postgresql://babar:celeste@1.2.3.4:5432/mydatabase

[flask]
port = 6666
secret = Azerty#Uiop

[logs]
level=INFO
handler=stdout

You can do the following:

from inireader import reader

cfg = reader('myapp.cfg')

assert cfg.sections() == ['', 'db', 'flask', 'logs']
assert cfg['']['hello'] == 'World'
assert cfg['flask'] == {'port': '6666', 'secret': 'Azerty#Uiop'}

#Differences with existing solutions

The python stdlib module does not support values out of sections.

The third party ConfigObj package does not handle '#' caracters within lines (they are interpreted as comment markers).

#Advanced features

It is possible to include a configuration file using the %include directive:

%include credentials.ini