Pit-Viper is a Python package that offers configuration management capabilities like the Viper package in Golang.
Project description
pit-viper
Pit-Viper is a Python package that offers configuration management capabilities like the Viper package in Golang.
Table of Contents
Installation
You can install pit-viper
using pip
:
pip install pit-viper
Usage
Environment Variables
The pit-viper
package provides the auto_env
function that loads environment
variables from a .env
file. The function returns a dict
of all existing
environment variables.
from pit import viper
env = viper.auto_env()
Config Files
Config files are another config source for pit-viper
. The package supports
loading, accessing, and setting defaults for a config. Supported file formats
are JSON, TOML, and YAML.
from pathlib import Path
from pit import viper
MY_CONFIG_DIR = Path() / "config"
viper.set_config_path(MY_CONFIG_DIR)
viper.set_config_name("my_config")
viper.set_config_type("toml")
viper.set("foo", "default-value")
viper.load_config()
bar = viper.get("foo")
nested_parameter = viper.get("my.nested.parameter")
Development
We use Poetry for packaging and
dependency management.
After installing Poetry, consider running the command below to configure Poetry
to create virtual environments in a folder named .venv
within the project's
root directory.
poetry config virtualenvs.in-project true
Afterward, you can run the install
command to install the dependencies
(including development requirements) specified in the pyproject.toml
or
poetry.lock
file.
poetry install
For a more comprehensive description of the Poetry setup and commands, see their documentation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for pit_viper-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb89e6e09aae013cbb11e58afd0682be5ea9f6dcf589ac3117d5c692b48eba56 |
|
MD5 | 50711c30ab4950435b96a8fee88c5c6f |
|
BLAKE2b-256 | 11c6f65de33787a3956fd646a68d14bb92ffddbcd28a8785eab36d2ec470e885 |