Inireader provides a simple API to handle ini style files.
version 0.1.0 pushed on pypi
b8f7f093cc96 — Aurélien Campéas 0.1.0 3 years ago
start a small README
f9843a081501 — Aurélien Campéas 3 years ago
tests: aknowledge that the previous fix gave us `path` in first position

heads

default
browse log
0.1.0
browse .tar.gz

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