Skip to main content

iniconfig: brain-dead simple config-ini parsing

Project description

iniconfig: brain-dead simple parsing of ini files

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

  • tested against Python2.4 across to Python3.2, Jython, PyPy

  • 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:

http://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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iniconfig-1.0.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iniconfig-1.0.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file iniconfig-1.0.1.tar.gz.

File metadata

  • Download URL: iniconfig-1.0.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for iniconfig-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e5f92f89355a67de0595932a6c6c02ab4afddc6fcdc0bfc5becd0d60884d3f69
MD5 464179a74789d033b170101f6aa38c2a
BLAKE2b-256 aa6e60dafce419de21f2f3f29319114808cac9f49b6c15117a419737a4ce3813

See more details on using hashes here.

File details

Details for the file iniconfig-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: iniconfig-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for iniconfig-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80cf40c597eb564e86346103f609d74efce0f6b4d4f30ec8ce9e2c26411ba437
MD5 ad18af63810529a8992ce3482136c47d
BLAKE2b-256 2046d2f4919cc48c39c2cb48b589ca9016aae6bad050b8023667eb86950d3da2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page