pythonic层次配置分析器
pyerconf的Python项目详细描述
示例配置:
# a value is set with: key : value # values are typed. allowed types are: # - string (simple or double quotes) # - boolean (True or False. is case sensitive) # - integer strval : 'this is a string' boolval: True intval : 142 # you can define hierarchies with dictionaries # ! no comma to se orgchart : { boss : 'Mr Goldmine' head_office : { VP : 'Miz dho' CTO : 'John Bugs' } }
从python加载:
>>> import pyerconf >>> cfg = pyerconf.Config('./sample.cfg') >>> print cfg.strval this is a string >>> print cfg.orgchart.boss Mr Goldmine >>> print cfg.orgchart.head_office {'VP': 'Miz dho', 'CTO': 'John Bugs'} >>> print cfg.foobar AttributeError