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.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.1.0.tar.gz
(12.8 kB
view details)
Built Distribution
File details
Details for the file configyaml-0.1.0.tar.gz
.
File metadata
- Download URL: configyaml-0.1.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66a3e81d194cade1464c5ca822d1f70ba3e6c339510a0aa65768def553d729a8 |
|
MD5 | 5c83ceccd36c400302f48b37411baca9 |
|
BLAKE2b-256 | 84ae33fbb7b9ca58c3cf9a575301c58482c220f73542a6fee23233557ea7fea9 |
File details
Details for the file configyaml-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: configyaml-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 363409dc8d4762b8ecff0f4d74d2c0adc8728435d8f5d544c3251abb822fb3e1 |
|
MD5 | ab0001562873687ed916173c6849bd60 |
|
BLAKE2b-256 | b95ebb5163547c04f1e4ef6751b70a7a39fd5b0781cb9bc3be85b01430d49c1d |