Manage required and optional environment variables in your scripts.
Project description
# pyconfigvar
Manage required and optional environment variables in your Python scripts.
## Example
`sh $ REQUIRED_VAR="something" python `
`python >>> import pyconfigvar >>> pyconfigvar.requiredvar('REQUIRED_VAR') 'something' >>> pyconfigvar.requiredvar('MISSING_VAR') >>> pyconfigvar.requiredvar('MISSING_VAR') MISSING_VAR was not supplied in the environment. <drop back to shell> `
## Usage
There are four functions available:
### requiredvar(var)
Returns the contents of the environment variable var. If var is not present in the environment, sys.exit() is invoked to terminate the interpreter.
### optionalvar(var, default)
Like requiredvar(), but instead of terminating, default is returned.
### requiredbool(var)
Like requiredvar(), but will coerce the value of var into a boolean and return that. Essentially, anything non-zero or non-empty will return True, otherwise it will return False.
### optionalbool(var, default)
Like requiredbool(), but will return default rather than terminate the interpreter.
## Contributing
Pull request away!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for pyconfigvar-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43e7b373903ca3e464ca6efaea8eb2131eb26f2a1c4f7254c15e5795c653ed1e |
|
MD5 | 889848073ec345c60915964f5af32119 |
|
BLAKE2b-256 | f158680633a8d2f54a28189f24d3bcfaaa234f998c9b922371469c5a5a81ba4d |