集装箱应用的方便配置

container-app-conf的Python项目详细描述


容器应用程序配置https://badge.fury.io/py/container-app-confBuild Status

container app conf是一个易于读取应用程序值的库 从多个地方,比如一个yaml文件和环境变量 同时提供类型验证。

这个库的最初目的是有一个简单的配置方法 在某种容器中运行的应用程序(本例中为Docker) 使用环境变量,同时仍然提供使用 一种更简单的配置形式,如yaml文件。

如何使用

pip install container-app-conf

扩展Config

fromcontainer_app_confimportConfigfromcontainer_app_conf.entry.stringimportStringConfigEntryclassAppConfig(Config):@propertydefconfig_file_names(self)->[str]:return["my_app_config_file_name"]MY_CONFIG=StringConfigEntry(yaml_path=["my_app_config_file_name","example"],none_allowed=False)

配置类型

NameDescriptionType
^{}Parses ^{}, ^{} (^{} and ^{}) and ^{} values (^{}, ^{} etc.) to a boolean value^{}
^{}Parses input to an integer^{}
^{}Parses input to a floating number^{}
^{}Takes the raw string input^{}
^{}Parses a comma separated string to a list of items specified in another ^{} (in yaml it can also be specified as a yaml list)^{}
如果没有现有的类型适合您的需求,您可以轻松创建您的 通过扩展ConfigEntry基类来拥有。

默认值

通过使用 default构造函数参数。

允许None

默认情况下,仅当默认值为None时,才允许使用None值。 这意味着无法在示例中设置MY_CONFIG项 在顶部到None,即使在初始解析之后。指定空文本 在yaml或相应的环境变量中,将导致 例外。如果希望允许设置None值,可以使用 none_allowed构造函数参数。

贡献

github是用于社会编码的:如果您想编写代码,我鼓励通过forks的pull请求进行贡献 关于这个仓库。为bug和新特性创建github票证,并评论您感兴趣的特性。

许可证

container-app-conf
Copyright (c) 2019 Markus Ressel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java shibboleth idp获取用户属性   在Java FileWriter和FileReader中,是否可以使用对象?   java层多个BuffereImage相互重叠?   运行GWT/GAE应用程序时出现java时区错误   java事件。getX与圆的getLayoutX不对应   Axon中的java聚合vs AKKA中的Actor   内存如何测试对象引用在Java中使用了多少字节?   java如何使用一个方法的返回值作为另一个方法的参数?   在CentOS上启动Pentaho spoon时发生java JDK致命错误   java我在用逗号拆分字符串时遇到问题   java一个键上有多个键绑定?   java Jackson ObjectMapper处理JSON和非JSON输入   java Spring启动微服务,混合本地和远程服务   java无法删除行之间的空白   JavaSpring+Hibernate:创建bean时出错   Azure存储Java API:帐户不支持HTTP   如何实现基本API网关