Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Validates YAML/TOML based configuration files against JSON Schema specifications

License

Notifications You must be signed in to change notification settings

lamehost/schemed-yaml-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Schemed YAML Config

Schemed YAML Config is a library to read and validate YAML based configuration files against JSON Schema specifications.

Branches

The project is transitioning from v0.x to v1.x and master branch is used to develop the latter.
There's significant changes between v0.x and v1.x. And, while new user are encouraged to look into v1.x, that might be troublesome for those who have developed code around v0.x

Install

Schemed-yaml-config can be installed via PIP

# pip install schemed-yaml-config

Under the hood

Schemed YAML Config works by converting YAML files into a dictionarie by mean of the well known PyYAML framework and then by applying JSON Schema specifications before of returning it to rest of the script.
The beauty of this approach is it combines the human friendly serialization of YAML with the power of JSON Schema.

A few tricks has been added to make the library even more human friendly. For instance when the a configuration file is missing and a default is created, order and comments of the keys from the schema are borrowed to the YAML file.

Syntax

Python 3.7.4 (default, Aug 21 2019, 16:01:23)
[GCC 9.2.1 20190813] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from schemed_yaml_config import get_config
>>> config = get_config('config.yml', 'schema.yml')
>>> print(config.config)
{'listen': {'host': 'localhost', 'port': 8080}, 'tmpdir': '/tmp/'}
>>>

TOML

Despite its name Schemed YAML Config also supports TOML. TOML schemas are not supported yet!

Releases

No releases published

Packages

No packages published

Languages