A lightweight Python utility for loading and retrieving environment variables
Project description
Enventory
Enventory is a lightweight Python utility for accessing environment variables from the system with optional type casting, defaults, and required flags.
Features
- Access environment variables from the system with simple, clean API.
- Retrieve environment variables with default values, type casting, and required checks.
- Helper functions for casting strings to booleans or lists.
- Raises clear errors when required environment variables are missing.
- Compatible with Python 3.8+.
Installation
Once published to PyPI, you can install Enventory via pip:
pip install enventory
Or for local development:
git clone https://github.com/yourusername/enventory.git
cd enventory
pip install -e .
Usage
Access Environment Variables
from enventory import getenv, to_boolean, to_list
# Get a variable with optional default
db_host = getenv("DB_HOST", default="localhost")
# Get a required variable (raises ValueError if missing)
secret_key = getenv("SECRET_KEY", required=True)
# Cast a variable to boolean
debug_mode = getenv("DEBUG", default="False", cast=to_boolean)
# Cast a comma-separated variable to a list
allowed_hosts = getenv("ALLOWED_HOSTS", default="", cast=to_list)
Helper Functions
from enventory import to_boolean, to_list
to_boolean("yes") # True
to_boolean("0") # False
to_list("a,b,c") # ['a', 'b', 'c']
to_list("a;b;c", separator=";") # ['a', 'b', 'c']
Error Handling
ValueErroris raised bygetenvif a required environment variable is missing.
Project Structure
enventory/
├── setup.py
├── pyproject.toml
├── README.md
└── enventory/
├── __init__.py # exposes env.py
└── env.py # main environment utility
Contributing
Contributions, issues, and feature requests are welcome!
- Fork the repository
- Create a new branch (
git checkout -b feature-name) - Make your changes
- Submit a pull request
License
MIT License © Your Name
Compatibility
- Python 3.8 and above
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file enventory-0.0.3.tar.gz.
File metadata
- Download URL: enventory-0.0.3.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94e307dbe9e61c80b722ba539c9f0f57e7842524036bcf82113ebd079b24f5ab
|
|
| MD5 |
44a1ebcd0353eb14ad56c6752c0e2306
|
|
| BLAKE2b-256 |
191e15e911cbb82b1b164d66d5a7a92de6c521a157d6223dd00f645db887c3ec
|
File details
Details for the file enventory-0.0.3-py3-none-any.whl.
File metadata
- Download URL: enventory-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
283ea4ffffcf4a8ed08134e80ee31479f63f8f72bc53f730743ceadc8a594ef7
|
|
| MD5 |
f2833490f27661b7a949c2758d72d5b4
|
|
| BLAKE2b-256 |
e0827b352a3da3fcc55b069efe22805de5d1f33ad42ebf2f2f277a113aa69a3c
|