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.0.0.tar.gz
(5.7 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.0.0.tar.gz.
File metadata
- Download URL: gnvext-2.0.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d7d946a05d4c78f2d798cb1d8155f235e4423865c5bd467a5dc22739b029450
|
|
| MD5 |
5d269372d3c469164dc4de15763cd202
|
|
| BLAKE2b-256 |
2acca52de27ce047c70dffe2940f52dc61b2429bebf86d92f2a5d3859307e22d
|
File details
Details for the file gnvext-2.0.0-py3-none-any.whl.
File metadata
- Download URL: gnvext-2.0.0-py3-none-any.whl
- Upload date:
- Size: 7.8 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 |
815fa62930e957bf5775e96c1703dab1bbf3fa487a4f410643851e83b090102d
|
|
| MD5 |
6b46cbef9e824ab96bae962c5a93fea9
|
|
| BLAKE2b-256 |
93f4c1753a59e39f9502ee90e2033bed6c39a645b994d8c06db7d25f648ca54f
|