Skip to content

beaugunderson/python-tini

Repository files navigation

tini

A simple module for loading .ini-style configuration files.

Based on ConfigParser and works in Python 2 and Python 3.

Running tests

$ py.test

Or, with tox (test with multiple Python versions):

$ tox

Example

settings.py

import os
import sys

from tini import Tini

filenames = [
    './foobar.ini',
    os.path.join(os.path.expanduser('~'), '.foobar.ini'),
    os.path.join(os.path.expanduser('~'), '.config', '.foobar.ini'),
]

defaults = {
    'foobar': {
        'baz': 'a string',
        'buzz': True,
        'bizz': 123,
    }
}

sys.modules[__name__] = Tini(filenames, defaults=defaults)

foobar.ini

[foobar]
buzz = false

test.py

import settings

assert settings.foobar['baz'] == 'a string'
assert settings.foobar['buzz'] is False
assert settings.foobar['baz'] == 123

About

🐍 a simple Python module for loading .ini files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages