Varsubst is a rewrite of envsubst.
Varsubst render templates from a string with a given resolver.
Currently varsubst support shell-like variables.
Entry-point has currently been removed. It may be added in the future.
Resolvers provided are :
- EnvResolver : provide value based on environnement variables.
- DictResolver : provide value based on a given python dictionary.
Supported template variables
Varsubst support shell-like variables which are defined as follows:
- $MY_SIMPLE_VAR or ${MY_SIMPLE_VAR}: will resolve the variable MY_SIMPLE_VAR
- ${USER-default} : will resolve the variable USER. If variable is unset then default string is returned.
- ${USER-$DEFAULT_USER} : will resolve the variable USER. If variable is unset, resolve the variable DEFAULT_USER.
- ${USER:-default} : will resolve the variable USER. If variable is unset or empty then default string is returned.
- ${USER-$DEFAULT_USER} : will resolve the variable USER. If variable is unset or empty, resolve the variable DEFAULT_USER.
Usage
from varsubst import varsubst
from varsubst.resolvers import DictResolver
from varsubst.interpolators.jinja_interpolator import JinjaInterpolator
print(varsubst('$USER')) # result : 'tiboun'
print(varsubst('$UNDEFINED')) # result : KeyUnresolvedException('UNDEFINED')
print(varsubst('$UNDEFINED', fail_on_unresolved=False)) # result : ''
print(varsubst('$UNDEFINED', fail_on_unresolved=False)) # result : ''
print(varsubst('$USER', resolver=DictResolver({'USER': 'tiboun'})))
print(varsubst('{{ USER }}', interpolator=JinjaInterpolator()))
Extras
You may install varsubst[jinja2] as well if you intend to interpolate template with Jinja. If you plan to use jinja2 only, you may install it yourself in your project instead of using this one.
Metadata
Release files for varsubst 2.0.0
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 |
|---|---|---|---|---|
| varsubst-2.0.0.tar.gz | 5.7 kB | Without provenance | Details for varsubst-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| varsubst-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for varsubst-2.0.0-py3-none-any.whl |
Total release size: 16.7 kB
Release files / varsubst-2.0.0.tar.gz
| Download URL | varsubst-2.0.0.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
54ed52fbc99ac085edd43c2d5e31e3bbd5f81fef39d4fd3b8bc180c65a908ec1
|
|
BLAKE2b-256 checksum How to use checksums |
6e5a1a195032b804fc31724c92f40b699366627403816dc92327762d7fc698ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
|
Release files / varsubst-2.0.0-py3-none-any.whl
| Download URL | varsubst-2.0.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eab0164e903180504143882c89f02576cceb097c29a341d92352171312c854ee
|
|
BLAKE2b-256 checksum How to use checksums |
4d14d0e330807284bbb151cd5d6ecda611aed99d2e894876ae384dc9b7ff13bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
|
Security for varsubst 2.0.0
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.