一种可扩展的配置,使您能够通过python模块、配置文件、环境变量等配置您的应用程序!
ultra_config的Python项目详细描述
超配置
一种可扩展的配置,使您能够通过python模块、配置文件、环境变量等配置您的应用程序!
- 自由软件:麻省理工学院许可证
- 文档:https://ultra-config.readthedocs.io。
安装
pip install ultra-config
功能
- 从各种源加载配置,包括环境变量、json文件、ini文件和python对象
- 使用自己的配置机制轻松扩展
- 为应用程序提供全局配置对象
- 轻松地将配置注入函数,并能够覆盖它们进行测试
- 如果缺少配置,则能够快速失败
示例
全局配置
fromultra_configimportGlobalConfig# Loads all env variables that begin with MY_APP, configuration# from a json file and a custom overrideGlobalConfig.load(env_var_prefix='MY_APP',json_file='/opt/my_app/config.json',overrides={'MY_VAR':'some_val'})@GlobalConfig.inject('MY_VAR',value='OTHER_VAR')defmy_func(arg1,value=None):print(arg1)print(value)my_func()# Prints the value of MY_VAR and OTHER_VARmy_func(value='custom')# prints the value of MY_VAR and then prints the "custom" since we explicitly passed that in
学分
这个包是用Cookiecutter和audreyr/cookiecutter-pypackage项目模板创建的。
历史记录
0.1.0(2016-07-22)
- pypi上的第一个版本。