Skip to main content

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:

  • 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

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-2.2.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

iniconfig-2.2.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: iniconfig-2.2.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iniconfig-2.2.0.tar.gz
Algorithm Hash digest
SHA256 1807d2bc2eb4231a5e40e2ecee093fc25fc0eb0e2840f01ea50a1d15380adbff
MD5 9b26b3dc5b58de889eb51e2a700280a4
BLAKE2b-256 8e112f7713979d561602e14b8fdd99a0e2e8ff2d901de1041c42a23a4c33f2c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for iniconfig-2.2.0.tar.gz:

Publisher: test.yml on pytest-dev/iniconfig

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: iniconfig-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iniconfig-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eeea4a571b616cf2951fbeeda9490863f3d1882a21cf673cd3236545488d6f1e
MD5 a6e96926f6896a63dc1113d24e12b96a
BLAKE2b-256 13713970abe530a7a15e406874a30ed6cf1ead266444b4503ebb2f68b4d98f30

See more details on using hashes here.

Provenance

The following attestation bundles were made for iniconfig-2.2.0-py3-none-any.whl:

Publisher: test.yml on pytest-dev/iniconfig

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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