internal/tools/: iniconfig-2.0.0 metadata and description

Simple index

brain-dead simple config-ini parsing

author_email Ronny Pfannschmidt <opensource@ronnypfannschmidt.de>, Holger Krekel <holger.krekel@gmail.com>
classifiers
  • Development Status :: 4 - Beta
  • Intended Audience :: Developers
  • License :: OSI Approved :: MIT License
  • Operating System :: MacOS :: MacOS X
  • Operating System :: Microsoft :: Windows
  • Operating System :: POSIX
  • Programming Language :: Python :: 3
  • Programming Language :: Python :: 3 :: Only
  • Programming Language :: Python :: 3.7
  • Programming Language :: Python :: 3.8
  • Programming Language :: Python :: 3.9
  • Programming Language :: Python :: 3.10
  • Programming Language :: Python :: 3.11
  • Topic :: Software Development :: Libraries
  • Topic :: Utilities
description_content_type text/x-rst
project_urls
  • Homepage, https://github.com/pytest-dev/iniconfig
requires_python >=3.7
File Tox results History
iniconfig-2.0.0-py3-none-any.whl
Size
6 KB
Type
Python Wheel
Python
3
iniconfig-2.0.0.tar.gz
Size
5 KB
Type
Source

iniconfig: brain-dead simple parsing of ini files

iniconfig is a small and simple INI-file parser module having a unique set of features:

  • maintains order of sections and entries

  • supports multi-line values with or without line-continuations

  • supports “#” comments everywhere

  • raises errors with proper line-numbers

  • no bells and whistles like automatic substitutions

  • iniconfig raises an Error if two sections have the same name.

If you encounter issues or have feature wishes please report them to:

https://github.com/RonnyPfannschmidt/iniconfig/issues

Basic Example

If you have an ini file like this:

# content of example.ini
[section1] # comment
name1=value1  # comment
name1b=value1,value2  # comment

[section2]
name2=
    line1
    line2

then you can do:

>>> import iniconfig
>>> ini = iniconfig.IniConfig("example.ini")
>>> ini['section1']['name1'] # raises KeyError if not exists
'value1'
>>> ini.get('section1', 'name1b', [], lambda x: x.split(","))
['value1', 'value2']
>>> ini.get('section1', 'notexist', [], lambda x: x.split(","))
[]
>>> [x.name for x in list(ini)]
['section1', 'section2']
>>> list(list(ini)[0].items())
[('name1', 'value1'), ('name1b', 'value1,value2')]
>>> 'section1' in ini
True
>>> 'inexistendsection' in ini
False