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.2.tar.gz (2.8 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.2-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file pyamlconf-0.0.2.tar.gz.

File metadata

  • Download URL: pyamlconf-0.0.2.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for pyamlconf-0.0.2.tar.gz
Algorithm Hash digest
SHA256 dd3e88f81e65fbaff3aeaf9993200eb9a3b7e6c589f6bf0dff8763349193a847
MD5 26f01953af65339477a30bd65279f27c
BLAKE2b-256 0aa69e519986169fb4b75d446a9938fb9b269261020e7713d49722f7ada0c7ed

See more details on using hashes here.

File details

Details for the file pyamlconf-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyamlconf-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for pyamlconf-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cebed8c80fd0a1a1ef5bc8b78751c45825f15ab30aed54501a3f1ce208c0fcfa
MD5 9e7791939c9d234e0a9690e7ab638da4
BLAKE2b-256 6d00f82595c693e94d6cddf9062e5e7dcc8760791ae61def5a7cfa311adc9532

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