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 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

hyperconf-0.3.0.tar.gz (11.6 kB view hashes)

Uploaded Source

Built Distribution

hyperconf-0.3.0-py3-none-any.whl (12.9 kB view hashes)

Uploaded Python 3

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