集装箱应用的方便配置

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 Spring MVC 4.0 RequestMapping无值,基于methodname   java Samsung 10 plus不允许wifi p2p发现   春爪哇。伊奥。IOException:找不到文件   java JasperReport饼图示例   java我试图使用mockito注释来测试我的代码,但无法解决mockito异常   命令行界面Java:制作简单的交互式cli应用程序   java jdk1之间的区别是什么。7_9 9和jdk1。7_271   java重载一个被重写的、继承的方法   java LazyInitializationException春季启动   java Play Framework 2.2.1 3个表之间存在大量关系