Skip to main content

configyaml

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.2 (2019-09-02)

  • Fix KeyError when using as_dict() with a missing required dict field

0.5.1 (2018-03-30)

  • Fix ListNode passing wrong yaml node for child

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.

Metadata

Release files for configyaml 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for configyaml 0.5.2
File Size Uploaded
configyaml-0.5.2.tar.gz 16.6 kB Details

Release files / configyaml-0.5.2.tar.gz

Download URL configyaml-0.5.2.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
af228e723c49f5b8c12004e0975bd44e5a85073e227cfd2f0d1571045a5c73bd
BLAKE2b-256 checksum
How to use checksums
30c2705dbba0c9eabf7f6a4bf2879f1eb065eaf0b26fd07488fd657436d6d3a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.15

Release history Release notifications | RSS feed

This release

0.5.2 This release

1 release file

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

1 release file

0.3.0

1 release file

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page