Wrapper for converting environment variables to any python type
Project description
gnvext
Wrapper for converting environment variables to any python type
Installing
Python 3.10+ is required
[!NOTE] It's recommended to activate Virtual Environment before installing gnvext
To clone and install required packages use the following command:
# linux/macOS
$ python3 -m pip install gnvext
# windows
$ py -3 -m pip install gnvext
Quick example
import gnvext
# you can load .env file here
# if "PRINT_HELLO_WORLD" env variable exists,
# then extracts it, otherwise, raises ValueError.
# (raises only if default is a subclass of BaseException (or its instance),
# in another case, returns default as-is)
PRINT_HELLO_WORLD = gnvext.BooleanEnvVariable(
name="PRINT_HELLO_WORLD",
default=ValueError("we don't know if we should greet world or not :("),
).value
if PRINT_HELLO_WORLD:
print("Hello, world!")
# output for PRINT_HELLO_WORLD=True
# Hello, world!
# output for PRINT_HELLO_WORLD=False
#
# output for PRINT_HELLO_WORLD=None
# ValueError: could not convert "None" to bool
# output for undeclared env var PRINT_HELLO_WORLD
# ValueError: we don't know if we should greet world or not :(
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
gnvext-2.1.2.tar.gz
(5.9 kB
view details)
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 gnvext-2.1.2.tar.gz.
File metadata
- Download URL: gnvext-2.1.2.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89396ab9aa4790e798b0b4c3d8c6f56a2e55c59c0f7e3650ccbb7a816d3ac08e
|
|
| MD5 |
63dafb1fe35c73653a225c57943a470c
|
|
| BLAKE2b-256 |
81a3396429c6dbd77236b0e5061fbec72874969aa781710b5639dff005ead639
|
File details
Details for the file gnvext-2.1.2-py3-none-any.whl.
File metadata
- Download URL: gnvext-2.1.2-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9085261ebd02e6e548fa06c8ed4c144b09bdd44fef9153563293ef95ffbdc888
|
|
| MD5 |
453654b06fa1d6f60b0c2ea9c12d794a
|
|
| BLAKE2b-256 |
15fcfeb8dfbe5de8c8fafd4f5deac12d06c46ebf7f051f7ce5f6c41aaaa1b1f8
|