Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

shaneing/python-viper

Repository files navigation

Python Viper

This project was inspired by spf13/viper.

Installation

pip install py-viper

Usage

import tempfile
import viper
yaml_example = b'''
hello:
 name: foo
'''
class Hello:
 name = ''
class Config:
 hello = Hello
if __name__ == '__main__':
 with tempfile.NamedTemporaryFile(suffix='.yaml') as temp:
 temp.write(yaml_example)
 temp.seek(0)
 viper.set_config_path(temp.name)
 viper.read_config()
 assert viper.get('hello.name') == 'foo'
 conf = Config()
 viper.unmarshal(conf)
 assert conf.hello.name == 'foo'

You can also use remote config instead of local config:

viper.set_config_type('yml')
viper.set_remote_provider('consul', '127.0.0.1', 8500, 'hello')
viper.read_remote_config()

Note:

  • The config type only supports yaml or yml.
  • The backend of remote config only supports consul.

TODO

  • Read remote config
  • Unmarshal config
  • Add support for JSON

About

Python configuration

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /