Welcome to Inirama documentation

_images/logo.png

Inirama is a python module that parses INI files.

Build Status Coverals Version Downloads Donate

Inirama – Simplest parser for INI-style files.

Features:

  • One single module;
  • No requirements;
  • Tiny interface;
  • Supports variable interpolation;
copyright:2013 by Kirill Klenov.
license:BSD, see LICENSE for more details.

User’s Guide

This part of the documentation will show you how to get started in using Inirama.

Requirements

  • python (2.6, 2.7, 3.2, 3.3)

Installation

Inirama could be installed using pip:

pip install inirama

Contents

Quickstart

from inirama import Namespace

ns = Namespace()
ns.read('config.ini')

print ns['section']['key']

ns['other']['new'] = 'value'
ns.write('new_config.ini')

API Reference

If you are looking for information on a specific function, class or method, this part of the documentation is for you.

API

This part of the documentation documents all the public classes and functions in Inirama.

Namespace

class inirama.Namespace(**default_items)

Default class for parsing INI.

Parameters:**default_items

Default items for default section.

from inirama import Namespace

ns = Namespace()
ns.read('config.ini')

print ns['section']['key']

ns['other']['new'] = 'value'
ns.write('new_config.ini')
default

Return default section or empty dict.

:return inirama.Section: section

parse(source, update=True, **params)

Parse INI source as string.

Parameters:
  • source – Source of INI
  • update – Replace alredy defined items
read(*files, **params)

Read and parse INI files.

Parameters:
  • *files

    Files for reading

  • **params

    Params for parsing

Set update=False for prevent values redefinition.

section_type

alias of Section

write(f)

Write namespace as INI file.

Parameters:f – File object or path to file.

Interpolation Namespace

class inirama.InterpolationNamespace(**default_items)

That implements the interpolation feature.

from inirama import InterpolationNamespace

ns = InterpolationNamespace()
ns.parse('''
    [main]
    test = value
    foo = bar {test}
    more_deep = wow {foo}
''')
print ns['main']['more_deep']  # wow bar value

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/inirama/issues

Contributing

Development of inirama happens at github: https://github.com/klen/inirama

Contributors

  • klen (Kirill Klenov)

License

Licensed under a BSD license.