Some environment related functions.
Project description
Some environment related functions.
Latest release 20230407: getenv: new parse callable parameter to parse the value.
-
LOGDIR, VARRUN, FLAGDIR: lambdas defining standard places used in other modules
-
envsub: replace substrings of the form '$var' with the value of 'var' from
environ
. -
getenv: fetch environment value, optionally performing substitution
Function envsub(s, environ=None, default=None)
Replace substrings of the form '$var' with the value of 'var' from environ.
Parameters:
environ
: environment mapping, defaultos.environ
.default
: value to substitute for unknown vars; ifdefault
isNone
aValueError
is raised.
Function getenv(var, default=None, environ=None, dosub=False, parse=None)
Fetch environment value.
Parameters:
var
: name of variable to fetch.default
: default value if not present. If not specified or None, raise KeyError.environ
: environment mapping, defaultos.environ
.dosub
: if true, use envsub() to perform environment variable substitution ondefault
if it used. Default value isFalse
.parse
: optional callable to parse the environment variable; NOTE: if this raisesValueError
and there is a default, issue a warning and returndefault
Function LOGDIR(environ=None)
various standard locations used in the cs.* modules
Release Log
Release 20230407: getenv: new parse callable parameter to parse the value.
Release 20190103:
- Drop getLogin and getHomeDir, unused.
- Make get_standard_var private as _get_standard_var.
Release 20170905.1: Tweak doco and DISTINFO.
Release 20170905: Add LOGDIR, VARRUN, FLAGDIR wrappers for new get_standard_var function to provide standard policy variables.
Release 20160828: Update metadata with "install_requires" instead of "requires".
Release 20150118: Initial PyPI release.
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
Hashes for cs.env-20230407-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f44fb78adc286b7bd93ae01337e6e5c1669a48ba564928c887c4162d459c9502 |
|
MD5 | 2fc121326a78b2647cfbeddeb6601dfd |
|
BLAKE2b-256 | 7f669d3aeaf06120240e5d0c54d7a50ae27ecbaea49082bed315e93a02b23216 |