YAML-based configuration library, featuring zero-code validation and parsing.
Project description
HyperConfig
Overview
HyperConfig is a Python library for creating schema-based configuration. It allows zero code configuration definition where both the structure and the configuration values are validated using YAML based schema definition files.
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 hyperconfig
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: float
validator: 0.0 <= hval <= 1.0
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.2.3.tar.gz
.
File metadata
- Download URL: hyperconf-0.2.3.tar.gz
- Upload date:
- Size: 12.4 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 | 2758ef794edc82182691f0d08c9b552140e894d666b0e429a5147faaed13e8b5 |
|
MD5 | 18ed770102d00942cb4657e6b763f965 |
|
BLAKE2b-256 | 709b909390db9c392cf66efa88e8393c4c5c7900fc6ed841cd29981bf3225da0 |
File details
Details for the file hyperconf-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: hyperconf-0.2.3-py3-none-any.whl
- Upload date:
- Size: 13.5 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 | a50d28e101bb39fee6bb09c51d38f1c46dc2d735b565566640168fdc88907ea4 |
|
MD5 | cb64434995fc5fb67d79bd54d26652fb |
|
BLAKE2b-256 | 7ccd647b5792282e8b9348dc9de7901111b32406e3b4e02ca819a922b556d099 |