README.txt 1.5 KB

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