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