Skip to main content

YAML-based configuration library, featuring zero-code validation and parsing.

Project description

HyperConfig

Build Status PyPI version License

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

hyperconf-0.2.2.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

hyperconf-0.2.2-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file hyperconf-0.2.2.tar.gz.

File metadata

  • Download URL: hyperconf-0.2.2.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

Hashes for hyperconf-0.2.2.tar.gz
Algorithm Hash digest
SHA256 972deeb11013a15cff67ee1b23bb949e5e46d067641704db7ebb51957f9eaae5
MD5 7cd2fea2bb354856421ac7036611fba3
BLAKE2b-256 754a6bc420f237bb275651b0abc1fbb3685f008d25973637eb3ac980680afb6b

See more details on using hashes here.

File details

Details for the file hyperconf-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: hyperconf-0.2.2-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

Hashes for hyperconf-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 49fc94a46aa0f262a1ac4e0ee19cf549a6c52d7e39c186adcd820ea6dbf3579e
MD5 7ea428435b3f11ee2ca0a934ca744d24
BLAKE2b-256 6c672e3f2847f60b9dcde830f90fa21a71c5da9825ea9d96745c355d475eddfb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page