viaenv - Configuration via Environment for Python
viaenv uses variable annotation
to populate values from environment variables.
Example
from datetime import timedelta
from viaenv import populate_from_env
class config:
port: int = 8080
log_file: str = '/var/log/server.log'
timeout: timedelta = timedelta(milliseconds=100)
populate_from_env(
config, prefix='SRV',
# If you don't pass env, populate_from_env will use os.environ
env={'SRV_PORT': '9000', 'SRV_TIMEOUT': '300ms'})
print(config.port) # 9000
print(cfg.timeout == timedelta(milliseconds=300) # True
Supported Types
bool:y,yes,t,true,on,1->True,n,no,f,false,off,0->Falsedate:2019-05-18datetime:2019-05-18T13:43:12dict:{"x": 1, "y": 2}(JSON format)float:1.3,1e7int:12,0x12,0o12,0b12list:[1, 2, 3](JSON format)str: Anything goestime:13:43:12timedelta:10us,20ms,30s,17m,2h,7d,1h20m
You can add your types by calling register_type_parser(typ, parser) where
typ is a type (e.g. float) and parser is a one argument function that
will get the value as a string.
Metadata
Release files for viaenv 0.2.1
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 |
|---|---|---|---|---|
| viaenv-0.2.1.tar.gz | 4.8 kB | Without provenance | Details for viaenv-0.2.1.tar.gz |
Release files / viaenv-0.2.1.tar.gz
| Download URL | viaenv-0.2.1.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1de70355a7e16f54aebb3bb9cb95e82deb206a92130d1ba526d1bac82ae1e6d
|
|
BLAKE2b-256 checksum How to use checksums |
09e7ee21ea275d503b553381e570c1e340f76e961c7498545e26a31297b4761f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.7.4
|
Security for viaenv 0.2.1
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.