Expand system variables Unix style
Project description
expandvars
Expand system variables Unix style
Inspiration
This module is inspired by GNU bash's variable expansion features. It can be used as an alternative to Python's os.path.expandvars function.
This can be better utilized to read variables from config files to get the capability to read values from environment variables. For example:
[default]
my_secret_access_code = "${ACCESS_CODE:-default_access_code}"
NOTE: Although it copies most of the common behaviours, it doesn't follow it strictly. For example, it doesn't work with arrays.
Usage
from expandvars import expandvars
print(expandvars("$PATH:$HOME/bin:${SOME_UNDEFINED_PATH:-/custom/path}"))
# /bin:/sbin:/usr/bin:/usr/sbin:/home/you/bin:/custom/path
Examples
For now, refer to the test cases to see how it behaves.
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 Distribution
Built Distribution
File details
Details for the file expandvars-0.1.2.tar.gz
.
File metadata
- Download URL: expandvars-0.1.2.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b89892111a2da71aed0d6b4eab12ee38bb128cc4985c0407010b6df6e5a722e2 |
|
MD5 | 4332b34d67fdbf718ea54b0588effc0c |
|
BLAKE2b-256 | c4a74cf02a87dfa732a6dccb0103cd84001580de564fd2cd1a00df955ddec68c |
File details
Details for the file expandvars-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: expandvars-0.1.2-py3-none-any.whl
- Upload date:
- Size: 2.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6057b72baa6e2d9693b411b6e2f9fc3a7a5bf2b38b4b36c9d496a942b3a02ea3 |
|
MD5 | 97a6aad387a810a0aaf3f4498113b28e |
|
BLAKE2b-256 | fb2a3d3ec0c5e17b8da18bc811c5b4b63696cd4431a55c2f4d6fb72a7e2d9749 |