README.txt (1520B)
1 iniconfig: brain-dead simple parsing of ini files 2 ======================================================= 3 4 iniconfig is a small and simple INI-file parser module 5 having a unique set of features: 6 7 * tested against Python2.4 across to Python3.2, Jython, PyPy 8 * maintains order of sections and entries 9 * supports multi-line values with or without line-continuations 10 * supports "#" comments everywhere 11 * raises errors with proper line-numbers 12 * no bells and whistles like automatic substitutions 13 * iniconfig raises an Error if two sections have the same name. 14 15 If you encounter issues or have feature wishes please report them to: 16 17 http://github.com/RonnyPfannschmidt/iniconfig/issues 18 19 Basic Example 20 =================================== 21 22 If you have an ini file like this:: 23 24 # content of example.ini 25 [section1] # comment 26 name1=value1 # comment 27 name1b=value1,value2 # comment 28 29 [section2] 30 name2= 31 line1 32 line2 33 34 then you can do:: 35 36 >>> import iniconfig 37 >>> ini = iniconfig.IniConfig("example.ini") 38 >>> ini['section1']['name1'] # raises KeyError if not exists 39 'value1' 40 >>> ini.get('section1', 'name1b', [], lambda x: x.split(",")) 41 ['value1', 'value2'] 42 >>> ini.get('section1', 'notexist', [], lambda x: x.split(",")) 43 [] 44 >>> [x.name for x in list(ini)] 45 ['section1', 'section2'] 46 >>> list(list(ini)[0].items()) 47 [('name1', 'value1'), ('name1b', 'value1,value2')] 48 >>> 'section1' in ini 49 True 50 >>> 'inexistendsection' in ini 51 False