Source

iniconfig /

Filename Size Date modified Message
189 B
45 B
1.0 KB
52 B
1.4 KB
35 B
142 B
4.3 KB
1.3 KB
6.1 KB
193 B

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://bitbucket.org/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')]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.