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:
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
Release history Release notifications | RSS feed
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.0.0.tar.gz
(4.6 kB
view details)
Built Distribution
File details
Details for the file iniconfig-2.0.0.tar.gz
.
File metadata
- Download URL: iniconfig-2.0.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 |
|
MD5 | 3c030b3f51dcc3aca585de05635600e4 |
|
BLAKE2b-256 | d74bcbd8e699e64a6f16ca3a8220661b5f83792b3017d0f79807cb8708d33913 |
File details
Details for the file iniconfig-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: iniconfig-2.0.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374 |
|
MD5 | e423f20fe6712d80df7a23f9de303213 |
|
BLAKE2b-256 | efa662565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46 |