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.1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

hyperconf-0.2.1-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hyperconf-0.2.1.tar.gz
  • Upload date:
  • Size: 12.3 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.1.tar.gz
Algorithm Hash digest
SHA256 6171da764297a70a256dc9b79ef09726ab9fa009989527918d8cbbf93618b55a
MD5 40047e338651117d6d2bdf104d63e362
BLAKE2b-256 74666296d913e1b3c36da3aafc5e6fcb4bcf0d3392c360cf7d52728035697075

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hyperconf-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7632d4e5aeb352b7f5d8353ce61adf1bd63b2a34c981d2a2eb9100ac28f0f884
MD5 f865f89e291210d74868126390996ca3
BLAKE2b-256 d1ebb286bf6bd81a3144d338ca9dc4f05fa9ecc12cdba4a1edadff27a5fb4056

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