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
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-1.1.1.tar.gz
(8.1 kB
view hashes)
Built Distribution
Close
Hashes for iniconfig-1.1.1-py2.py3-none-any.whl
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | 011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3 |
|
| MD5 | 90f3e1bb7ced782f2b04eb5af266ecb7 |
|
| BLAKE2-256 | 9bddb3c12c6d707058fa947864b67f0c4e0c39ef8610988d7baea9578f3c48f3 |