Yaml configuration made lazy
TODO
Python 2.6+ or 3.2+ or PyPy.
Create a configuration file (YAML):
redis:
db: 0
pwd: 'test'
host: 'localhost'
port: 6379
Import lazyconfig
to your project:
import redis
from lazyconfig import lazyconfig
lazyconfig.set_config_file('my_config_file.yaml')
redis.Redis(host=lazyconfig.config.redis.host,
port=lazyconfig.config.redis.port,
db=lazyconfig.config.redis.db,
password=lazyconfig.config.redis.pwd)
Notes:
- By default you don't need to call
set_config_file
if your configuration file isconfig.yaml
and located in the App root directory.- This lib is not lazy load at all. The configuration file is loaded if you call
lazyconfig.config
orlazyconfig.load()
.- Loaded once, you don't need to load again. If so, call
lazyconfig.reload()
.
Well, if you're a Django user, you know that Django settings is a really good stuff. But how about your small project? This is a lib that helps you to configure your App is a similar way.
python tests/test.py
MIT