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

Uploaded Source

Built Distribution

iniconfig-2.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: iniconfig-2.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for iniconfig-2.1.0.tar.gz
Algorithm Hash digest
SHA256 3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7
MD5 437ede5b20b0ab2e76ca08f02b5c49dd
BLAKE2b-256 f297ebf4da567aa6827c909642694d71c9fcf53e5b504f2d96afea02718862f3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: iniconfig-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for iniconfig-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760
MD5 a3addcf2db108b0a2fd70a26e2504f22
BLAKE2b-256 2ce1e6716421ea10d38022b952c159d5161ca1193197fb744506875fbb87ea7b

See more details on using hashes here.

Supported by

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