Mercurial > hgrepos > Python > libs > ConfigMix
changeset 243:57ff12610dc5
Implemented OS:node to return the host's computername
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 21 May 2020 08:32:37 +0200 |
| parents | bfa4d125fd14 |
| children | 6d473abe308d |
| files | CHANGES.txt configmix/variables.py docs/introduction.rst |
| diffstat | 3 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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":
--- 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
