From 64da5a5320364e3efbaad51e40ed708abda01185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com> Date: Fri, 11 May 2012 15:15:35 +0200 Subject: [PATCH] cli: Make FormatParameterDict recursive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is useful if you have nested parameter dicts like in diskparams. Signed-off-by: RenΓ© Nussbaumer <rn@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/cli.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/cli.py b/lib/cli.py index e3ec55d27..2d292ec6b 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -3342,9 +3342,18 @@ def FormatParameterDict(buf, param_dict, actual, level=1): """ indent = " " * level + for key in sorted(actual): - val = param_dict.get(key, "default (%s)" % actual[key]) - buf.write("%s- %s: %s\n" % (indent, key, val)) + data = actual[key] + buf.write("%s- %s:" % (indent, key)) + + if isinstance(data, dict) and data: + buf.write("\n") + FormatParameterDict(buf, param_dict.get(key, {}), data, + level=level + 1) + else: + val = param_dict.get(key, "default (%s)" % data) + buf.write(" %s\n" % val) def ConfirmOperation(names, list_type, text, extra=""): -- GitLab