A config loading and parsing package
Project description
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.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
Built Distribution
File details
Details for the file configyaml-0.4.1.tar.gz
.
File metadata
- Download URL: configyaml-0.4.1.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11ddda5a443e2f030aed528d4676d298faa2e7ebcdad6a7b2992105863b58f72 |
|
MD5 | 8d8acdfa14f096c6deeec9e7773e0057 |
|
BLAKE2b-256 | c81dcc916f2be683dbd13fdc12e858470a7c80b33f03efc0a1bbb90fddef77f2 |
File details
Details for the file configyaml-0.4.1-py2.py3-none-any.whl
.
File metadata
- Download URL: configyaml-0.4.1-py2.py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c02f4c34cb3ef42671e95a81fea36bde64ad05f0dfe96e8b6586852ef87cad9c |
|
MD5 | b40a8abca3d888d9e5a308bb74685476 |
|
BLAKE2b-256 | ed3cb8adc7104a784501b82feb9db7498164ee50869b14c5b66391864d0e57f0 |