ExenENV
Environment variables verifier and type converter.
Installation
Library is available for installation from PyPI
$ pip install exenenv
Basic Usage
import os
from exenenv import EnvironmentProfile
os.environ["REQUIRED_VARIABLE"] = "20" # assume it's set to this
class Environment(EnvironmentProfile):
REQUIRED_VARIABLE: int
DEFAULT_VALUE_VARIABLE: float = 30.0
env = Environment()
env.load()
print(f"{env.REQUIRED_VARIABLE=}\n{env.DEFAULT_VALUE_VARIABLE=}")
env.REQUIRED_VARIABLE=20
env.DEFAULT_VALUE_VARIABLE=30.0
Using EnvVars
import os
from exenenv import EnvironmentProfile, EnvVar
os.environ.update({
"REQUIRED_VAR": "10",
"ALT_NAME_VAR": "40",
"CONVERTER_VAR": "gamer,coder,python"
}) # assume our environment is this
class Environment(EnvironmentProfile):
REQUIRED_VAR: int
DEFAULT_VALUE_VAR: str = EnvVar(default=20)
OTHER_VAR: int = EnvVar(env_name="ALT_NAME_VAR")
CONVERTER_VAR: list[str] = EnvVar(converter=lambda x: x.split(","))
env = Environment()
env.load()
print(f"""\
{env.REQUIRED_VAR=}
{env.DEFAULT_VALUE_VAR=}
{env.OTHER_VAR=}
{env.CONVERTER_VAR=}
""")
env.REQUIRED_VAR=10
env.DEFAULT_VALUE_VAR=20
env.OTHER_VAR=40
env.CONVERTER_VAR=['gamer', 'coder', 'python']
Union Typehints
Since v1.2, library supports converting to one of provided types.
import os
from exenenv import EnvironmentProfile
os.environ.update({
"UNION_VAR": "union"
})
class Environment(EnvironmentProfile):
UNION_VAR: int | str
OPTIONAL_VAR: float | None = None
env = Environment()
env.load()
print(f"{env.UNION_VAR=}\n{env.OPTIONAL_VAR=}")
env.UNION_VAR='union'
env.OPTIONAL_VAR=None
In this case, converting to UNION_VAR to int, so library used next provided type. Default value for OPTIONAL_VAR still has to be declared explicitly.
Metadata
Release files for exenenv 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| exenenv-1.2.tar.gz | 4.3 kB | Without provenance | Details for exenenv-1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| exenenv-1.2-py3-none-any.whl | Python 3 | none | any | Details for exenenv-1.2-py3-none-any.whl |
Total release size: 9.0 kB
Release files / exenenv-1.2.tar.gz
| Download URL | exenenv-1.2.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a4be67108f0d1128804b919b798cb4f56acd04a446b9f3907a0bb8abf1ae258
|
|
BLAKE2b-256 checksum How to use checksums |
172888f5aaf260091e76abc03c27507e2f8a7e31ff9ef0452843813d21e371a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.10.6 Linux/5.15.0-1024-azure
|
Release files / exenenv-1.2-py3-none-any.whl
| Download URL | exenenv-1.2-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ceb2de0c87a581c099d51076a246b5a43474ec466551fb7468a7078dea1000ee
|
|
BLAKE2b-256 checksum How to use checksums |
6b76980147f8fa3beadc6dc9e5451f373c7187961eb06ff36e29198450adb200
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.10.6 Linux/5.15.0-1024-azure
|
Security for exenenv 1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.