Skip to main content

A config loading and parsing package

Project description

https://travis-ci.org/dropseedlabs/configyaml.svg?branch=master https://img.shields.io/pypi/v/configyaml.svg https://img.shields.io/pypi/l/configyaml.svg https://img.shields.io/pypi/pyversions/configyaml.svg

Usage

The basic usage pattern is to extend these classes to create your own.

You need a loader:

from configyaml import loader

from .config.root import Root

class SibbellConfigLoader(loader.ConfigLoader):
    config_root_class = Root

Then design your config using additional classes. You need at least 1 to serve as the root class:

from configyaml.config import DictNode
from .dependencies import Dependencies
from .notifications import Notifications


class Root(DictNode):
    """Root of the yaml file"""

    def __init__(self, *args, **kwargs):
        self._dict_fields = {
                    'dependencies': {
                        'class': Dependencies,
                        'required': True,
                        'default': [],
                    },
                    'notifications': {
                        'class': Notifications,
                        'required': True,  # no point right now if no notifications
                        'default': [],
                    }
                }
        super(Root, self).__init__(*args, **kwargs)

    def _context_to_inject(self):
        """Make dependencies list available to notifcations"""
        return {'dependencies': self.dependencies}

Then to use it, simply create a loader using the configuration text content:

loader = SibbellConfigLoader(yaml_text)
# can now access the configuration and any other properties/method added to their classes
loader.is_valid()
loader.errors
loader.config_root.dependencies

History

0.5.0 (2018-03-30)

  • Add support for “variables”

0.4.1 (2018-01-31)

  • Give DictNode default instance access to parent and context

  • Update README badges

0.4.0 (2017-06-07)

  • Add RegexNode

  • DictNode fields know what their dict key was

0.3.0 (2017-05-31)

  • Add TypelessNode

  • Add BoolNode

  • Use yaml.safe_load

  • Allow DictNode field to have a default value of None

0.2.0 (2017-04-05)

  • Cleanup package release tooling and documentation

  • Fix a bit of broken documentation

  • Start some basic Sphinx documentation for classes

0.1.0 (2017-03-30)

  • First release on PyPI.

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

configyaml-0.5.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

configyaml-0.5.0-py2.py3-none-any.whl (14.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file configyaml-0.5.0.tar.gz.

File metadata

  • Download URL: configyaml-0.5.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for configyaml-0.5.0.tar.gz
Algorithm Hash digest
SHA256 2330f519e1c9f7903d936ba37aef84f8100357028e4ba412bb639a1f8aec2e02
MD5 54f2901560d074ea59a9c2d5b2d946fb
BLAKE2b-256 bd021f64dda0a895d1dfa44725b87b0759b34a92e05ea3b767892212ce8b649b

See more details on using hashes here.

File details

Details for the file configyaml-0.5.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for configyaml-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 301f1ebea6417724dd3ded708fe3570b3f97cd7367003bc81b4d1ba060bb1b27
MD5 699baca74e629adc93558a8173043420
BLAKE2b-256 02fb4fac4764a56dd3737ca4ff6b40fcae50141a62b2219f1e09a61aab4e69c2

See more details on using hashes here.

Supported by

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