# HG changeset patch # User Franz Glasner # Date 1590042757 -7200 # Node ID 57ff12610dc5722f993179ecf01d24448a63c5d1 # Parent bfa4d125fd144b64e96a95ab359f7ed8277a1afc Implemented OS:node to return the host's computername diff -r bfa4d125fd14 -r 57ff12610dc5 CHANGES.txt --- a/CHANGES.txt Thu May 21 08:19:03 2020 +0200 +++ b/CHANGES.txt Thu May 21 08:32:37 2020 +0200 @@ -22,6 +22,12 @@ The ``OS`` namespace lookup did not handle non-existing variables properly and ignored the `default` parameter. + .. change:: + :tags: feature + + Implemented new namespace function ``OS:node`` to return the node's + computername. + .. changelog:: :version: 0.7.3 diff -r bfa4d125fd14 -r 57ff12610dc5 configmix/variables.py --- a/configmix/variables.py Thu May 21 08:19:03 2020 +0200 +++ b/configmix/variables.py Thu May 21 08:32:37 2020 +0200 @@ -10,6 +10,7 @@ from __future__ import division, absolute_import, print_function import os +import platform from functools import wraps from .compat import PY2, native_os_str_to_text, u @@ -36,6 +37,8 @@ """Lookup some process and/or OS state """ if name == "cwd": return native_os_str_to_text(os.getcwd()) + elif name == "node": + return native_os_str_to_text(platform.node()) else: if default is _MARKER: raise KeyError("key %r not found in the namespace" % name) @@ -45,7 +48,6 @@ def _pylookup(name, default=_MARKER): """Lookup Python specific information""" - import platform if name == "version": return u(platform.python_version()) elif name == "implementation": diff -r bfa4d125fd14 -r 57ff12610dc5 docs/introduction.rst --- a/docs/introduction.rst Thu May 21 08:19:03 2020 +0200 +++ b/docs/introduction.rst Thu May 21 08:32:37 2020 +0200 @@ -258,6 +258,10 @@ ``cwd`` Contains the current working directory of the process + ``node`` + Contains the current node's computername (or whatever + :py:func:`platform.node` returns) + 3. The namespace ``ENV`` This namespace contains all the environment variables as they are