Skip to main content

Python high level configuration library

Project description

http://img.shields.io/pypi/v/pymlconf.svg Requirements Status https://travis-ci.org/pylover/pymlconf.svg?branch=master https://coveralls.io/repos/github/pylover/pymlconf/badge.svg?branch=master https://img.shields.io/badge/license-GPLv3-brightgreen.svg

pymlconf (Python YAML Configuration Library) helps to easily manage and access to your application configurations which was already Written in YAML language.

It can merge two or more configuration files according their names and automatically treat file-names as namespaces, or simply merge several parts of configuration(YAML-string or Python-dict) on arbitrary config node. for more informations see documentations.

Config file

# filename: config.yaml
app:
    root_dir: %(here)s

Python code:

# filename: config.py
from pymlconf import ConfigManager

config_str='''
app:
    name: MyApp
    listen:
        sock1:
            addr: %(hostname)s
            port: %(port)s
    languages:
        - english
        - {language: persian, country: iran}

logfile: /var/log/myapp.log
'''

cfg = ConfigManager(init_value=config_str, context=dict(hostname='192.168.0.1', port=8080))
cfg.load_files('path/to/config.yaml')

print cfg.app.name
print cfg.app.listen.sock1.addr
print cfg.app.languages[0]
print cfg.app.languages[1].country
print cfg.logfile

# --------- Prints:
# MyApp
# 192.168.0.1
# english
# iran
# /var/log/myapp.log

Deferred(Proxied)

# module configuration.py
from pymlconf import DeferredConfigManager
settings = DeferredConfigManager()

# another_module.py
from configuration import settings
def serve_request():
    return settings.message

# in application startup
from configuration import settings
settings.load(
    # the signature is the same as the `ConfigManager.__init__`
)

Installation

Latest stable version:

$ pip install pymlconf
# or
$ easy_install pymlconf

Development version:

$ pip install git+git@github.com:pylover/pymlconf.git

>From source:

$ cd source_dir
$ python setup.py install

Manually download it from pypi

Unit-Tests

Install nose and change current directory to project’s dir:

$ pip install nose
$ cd path/to/pymlconf

Running tests:

$ nosetests

Or

$ python setup.py test

Syntax Reference

You can find the canonical syntax reference on PyYAML site

Documentation

Change Log

  • [0.5.1] Encoding option for files

  • [0.4.0] Adding DeferredConfigManager

Project details


Release history Release notifications | RSS feed

This version

0.5.8

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymlconf-0.5.8.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

pymlconf-0.5.8-py2.py3-none-any.whl (19.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pymlconf-0.5.8.tar.gz.

File metadata

  • Download URL: pymlconf-0.5.8.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pymlconf-0.5.8.tar.gz
Algorithm Hash digest
SHA256 425a9ab2004f96a19a9a1b82ab2aafb776bd18b5c27d41617091307eb5d01a94
MD5 e17dbd9273724829fe9ae4bad6214fe1
BLAKE2b-256 c05420734745feb519b27cc30758ae3aac146fa9d8b46760fc52df08d58e0ee2

See more details on using hashes here.

File details

Details for the file pymlconf-0.5.8-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pymlconf-0.5.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7956f7b81561e7e2fb94a89adf466bff32c9fc7f4dfe7d909959591649e57757
MD5 53acbe63b93fa0650d40826e084b9d79
BLAKE2b-256 b641b1446824c59220d4f4f18f541826286cd901e6be201a06f72b22fb3f647d

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