oslo_config 项目

使用oslo_config项目来管理配置文件,下面算是一个Hello World。

from oslo_config import cfg

CONF = cfg.CONF

opts = [
    cfg.BoolOpt('enabled', default=False,
                help='Global toggle for caching.'),
    cfg.StrOpt('backend',
               default='',
               help='Where instances xml are stored on disk'),
    cfg.MultiStrOpt('backend_argument', default=[], secret=True,
                    help='Arguments supplied to the backend module. '
                         'Specify this option once per argument to be '
                         'passed to the dogpile.cache backend. Example '
                         'format: "<argname>:<value>".')
]

CONF.register_opts(opts, group="cache")

CONF(['--config-file', 'config.conf'])

print CONF.cache.enabled
print CONF.cache.backend
print CONF.cache.backend_argument
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,768评论 19 139
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 47,104评论 6 342
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,815评论 25 709
  • 22年12月更新:个人网站关停,如果仍旧对旧教程有兴趣参考 Github 的markdown内容[https://...
    tangyefei阅读 35,301评论 22 257
  • 9月6日早上开始 前一天晚上刷圈看到共同好友下的玩笑话,硬生生提醒着我,我们早就不是最开始的样子了。失眠,生气,对...
    慢点生活阅读 2,656评论 0 0