集装箱应用的方便配置

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第三方库


热门话题
Javaservlet,使用Quartz发送邮件   用Java编写XYRectangle类   java Docker/AWS ECS容器支持的服务(端点)数量   音频Java读取WAV文件作为浮点数组   java为什么是日历。九月不起作用了?   java连接到HTTPS url并发布到它   java线程动画示例不起作用   java查找HashMap是否包含所选值和返回键   java与后端API的交互   JavaFX启动时在JavaFX中执行应用程序启动异常   每T秒从Java运行一次MATLAB   java@Array(长度=?)怎么样OpenHFT中的注释/使用的值   java无法从InputStream读取多个可外部化的对象   java My RestController不返回对象的所有属性   java使Android XML阅读器只读取XML文件的一部分   java注释会影响编译时吗?   从Java到C#的迭代器方法与接口的等效性,然后在类上实现?   swing为什么Java中的侦听器相互依赖?