# HG changeset patch # User Franz Glasner # Date 1458289634 -3600 # Node ID d70b58b0dfb91dd32781601a2d7847fa3efa7d42 # Parent 17af7a78710c18d4252c554bc5c10e3bb830f2d7 A new variable namespace "OS" with a "cwd" function with new filters "abspath" and "normpath" for some minimal path manipulation diff -r 17af7a78710c -r d70b58b0dfb9 configmix/variables.py --- a/configmix/variables.py Fri Mar 18 09:13:06 2016 +0100 +++ b/configmix/variables.py Fri Mar 18 09:27:14 2016 +0100 @@ -28,7 +28,17 @@ return default -_varns_registry = {"ENV": _envlookup} +def _oslookup(name, default=_MARKER): + """Lookup an environment variable""" + if name == "cwd": + return native_os_str_to_text(os.getcwd()) + raise KeyError("key %r not found in the namespace" % name) + + +_varns_registry = { + "ENV": _envlookup, + "OS": _oslookup +} def lookup_varns(name): @@ -94,3 +104,13 @@ """ import passlib.utils return passlib.utils.saslprep(v) + + +@filter("normpath") +def normpath_impl(config, v): + return os.path.normpath(v) + + +@filter("abspath") +def abspath_impl(config, v): + return os.path.abspath(v)