用于加载应用程序配置的python配置库
configoo的Python项目详细描述
python配置
一个简单的库,用于从文件、环境等加载应用程序配置。配置变量在orm模型类maner中声明,以便于在代码中使用配置变量,并突出显示ide语法。
设置
待办事项:编写
示例
# config.pyfromconfigooimportModel,field,load_from_envclassConfig(Model):"""A simple configuration model. FOO - an integer value (default value is 123) BAR - a string value (must be specified in config source, otherwise the exception about missed field value will be thrown) """FOO=field.Integer(default=123)BAR=field.List(field.String(),required=True)# Load `Config` field from process environment.config=load_from_env(Config)# test.py# Assume environment contains:# FOO="321"# BAR="1,2,3"fromconfigimportconfigprint(config.FOO,type(config.FOO))# 321 <class 'int'>print(config.BAR,type(config.BAR))# [1, 2, 3] <class 'list'>