YAML-based configuration library, featuring zero-code validation and parsing.
Project description
HyperConfig
Overview
HyperConfig is a Python library for creating schema-based configuration files. It automatically parses parses, validates and converts configuration objects according to a predefined configuration schema.
Advantages:
- less code: define the structure in YAML, validate and load configs using a one-liner.
- shared schemas: define once, use in multiple projects.
- extensibility: add configuration types and validation rules without coding.
Installation
pip install hyperconf
Usage
Define your schema in a definition file, ships.yaml
:
# Spaceship Configuration Schema
ship_type:
type: str
validator: hval.isalpha()
required: true
shipcolor:
type: str
validator: hval.lower() in ['red', 'blue', 'green', 'yellow', 'gray']
required: true
enginepower:
type: int
validator: 100 <= hval <= 1000
required: true
shieldlevel:
type: percent
required: true
ship:
captain: str
crew:
type: int
validator: hval > 0
class: shiptype
color: shipcolor
shields: shieldlevel
engines: enginepower
Then use the schema to create configuration values, gameconfig.yaml
:
use: ships
ncc1701=ship:
captain: James T. Kirk
crew: 203
class: constitution
color: gray
shields: 1.0
engines: 900
and load it:
>>> from hyperconfig import HyperConf
>>> config = HyperConf.load("gameconfig.yaml")
>>> print(config.ncc1701.captain)
Please check the documentation at https://hyperconf.readthedocs.io/en/latest/index.html
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 hyperconf-0.3.0.tar.gz
.
File metadata
- Download URL: hyperconf-0.3.0.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.4 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca821ee5d6fbff8f701be420d9addb32f5dad86d4297f30be5db29d3d31e97e3 |
|
MD5 | 0e3d92767211f015395adf0cded6a0ee |
|
BLAKE2b-256 | 537ffb015c198d5a16cd740585d08ee51fba6e99d27bd743c07edbcb39b407c1 |
File details
Details for the file hyperconf-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: hyperconf-0.3.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.4 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c9e216fb7f8d126789a7047828e4d48938a072b53a0745ee4fee0168477f1c1 |
|
MD5 | f23d84119da2cac17b4b1bc8fa71262a |
|
BLAKE2b-256 | 22c10e115ac8628a6f96724701b25706606b62abeab70627a589d056083c649a |