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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyamlconf-0.0.3.tar.gz
  • Upload date:
  • Size: 3.0 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.3.tar.gz
Algorithm Hash digest
SHA256 e7f0087914719ec9784c580b88c777abc17e266d8d354cbd1c61be3fc17e33ea
MD5 7e696bd8828ff5b8072d6747bb437953
BLAKE2b-256 64c5ee3d24eebc19d2c309a89f5cf5b5f9075d731c9bfc329beff5575a4dc5ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyamlconf-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cc3124d84acd3a72c33c0e179d1e36d6d9d25521dd06de198a16d890d1e95c3a
MD5 a06fb45e875b45a81694b9e2ed52a5d3
BLAKE2b-256 0ef0c185e1002d11e34e3716f449bf31107507f27c83904024e74bd1473efed5

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