Skip to main content

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

pyamlconf-0.0.4.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyamlconf-0.0.4-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

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

Hashes for pyamlconf-0.0.4.tar.gz
Algorithm Hash digest
SHA256 4133b0ab50982beff5308850c7b50b4207f7c2d5666fbc0500fabd6673027575
MD5 74a569850a25c78b997e0b8ecb35fa7e
BLAKE2b-256 a853444aeea2de675f894116b6bd6862797694f0aec9453303570712192a9f28

See more details on using hashes here.

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

Hashes for pyamlconf-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8bd1cec77b57fa64bc19181e5538dc8e627e3c5ee17a440ff2e5a03d3b3af00a
MD5 b7e0b693f2fc7bcd526f9d41647835f7
BLAKE2b-256 bdb99078a0ba66c0889c9b9a84ff204c4631f4580e034187141fc45d8a84697a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page