A simple YAML-based configuration loader for Python
Project description
PyamlConf
A simple YAML-based configuration loader for Python
Mustache
bala bala..... see demo
Install
pip install pyamlconf
Demo
create yaml file on local path: tests/config.yaml
db:
url: mysql://{{.host}}:3306
host: 127.0.0.1
name: dbtest
pwd: 123456
pool:
size: 100
maxidle: 10
desc: "db.url = {{ db.url }}; db.name = {{ .name }}; db.pool = {{.pool}} "
create tests/test.py, like:
from pyamlconf.config import PyamlConfig
config = PyamlConfig('tests/config.yaml')
print(config.get('db.url'))
print(config.get('db.desc'))
run test
python tests/test.py
output:
mysql://127.0.0.1:3306
db.url = mysql://127.0.0.1:3306; db.name = dbtest; db.pool = {'size': 100, 'maxidle': 10}
update config
update with local config, use for development
create yaml file on local path: tests/config.local.yaml
db:
host: 127.0.0.1
pwd: 123456
modify python tests/test.py, like
from pyamlconf.config import PyamlConfig
config = PyamlConfig('tests/config.yaml')
print(config.get('db.url'))
print(config.get('db.desc'))
config.update(PyamlConfig('tests/config.local.yaml'))
print(config.get('db.url'))
print(config.get('db.desc'))
run test
python tests/test.py
output:
mysql://10.0.22.1:3306
db.url = mysql://10.0.22.1:3306; db.name = dbtest; db.pool = {'size': 100, 'maxidle': 10}
mysql://127.0.0.1:3306
db.url = mysql://127.0.0.1:3306; db.name = dbtest; db.pool = {'size': 100, 'maxidle': 10}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyamlconf-0.0.4.tar.gz.
File metadata
- Download URL: pyamlconf-0.0.4.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4133b0ab50982beff5308850c7b50b4207f7c2d5666fbc0500fabd6673027575
|
|
| MD5 |
74a569850a25c78b997e0b8ecb35fa7e
|
|
| BLAKE2b-256 |
a853444aeea2de675f894116b6bd6862797694f0aec9453303570712192a9f28
|
File details
Details for the file pyamlconf-0.0.4-py3-none-any.whl.
File metadata
- Download URL: pyamlconf-0.0.4-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bd1cec77b57fa64bc19181e5538dc8e627e3c5ee17a440ff2e5a03d3b3af00a
|
|
| MD5 |
b7e0b693f2fc7bcd526f9d41647835f7
|
|
| BLAKE2b-256 |
bdb99078a0ba66c0889c9b9a84ff204c4631f4580e034187141fc45d8a84697a
|