一个python到类来保存配置值。
configclass的Python项目详细描述
configClass—一个python到class的类,用于保存配置值
配置是一个带有where:
- existing items can be modified but no items can not be added
- has make() method so you can easily created derived configs
- make() has the same API as dict.update()
- make() will merge values according to mergedict.ConfigDict.merge()
- for convenience, make can take a None to perform a simple copy
>>> from configclass import Config >>> c1 = Config({'a': 1, 'b': ['foo']}) # can't add new items to config >>> c1.make({'a':2, 'c': [2]}) Traceback (most recent call last): KeyError: 'New items can not be added to Config, invalid key:c' # new config object created >>> c2 = c1.make({'a':2}) >>> c2 Config({'a': 2, 'b': ['foo']}) # original object is not modified >>> c1 Config({'a': 1, 'b': ['foo']}) # make() can take keyword arguments, note how lists are merged >>> c2.make(b=['bar']) Config({'a': 2, 'b': ['foo', 'bar']})<> > CytCopy.CuffMIXIN < /CIT>可用于创建
项目详细信息
- github上的项目管理-https://github.com/schettino72/configclass/
许可证
麻省理工学院的执照 版权所有(c)2014 Eduardo Naufel Schettino
请参见许可文件
开发人员/贡献者
- 爱德华多·诺费尔·谢蒂诺
安装
$ pip install configclass
或下载并:
$ python setup.py install
测试
在dev_requirements.txt中安装依赖项。
运行测试:
$ py.test