From 443e6bb8efd41f1e4bb42e1efdb37e9c3e22dc67 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 6 Jun 2019 09:24:51 +0200 Subject: menuconfig: Fix help display on Python 2 textwrap.indent() was added in Python 3.3. --- menuconfig.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'menuconfig.py') diff --git a/menuconfig.py b/menuconfig.py index 187df1c..77558eb 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -2616,8 +2616,7 @@ def _help_info(sc): for node in sc.nodes: if node.help is not None: - s += "Help:\n\n{}\n\n" \ - .format(textwrap.indent(node.help, " ")) + s += "Help:\n\n{}\n\n".format(_indent(node.help, 2)) return s @@ -2756,7 +2755,7 @@ def _kconfig_def_info(item): .format(node.filename, node.linenr, _include_path_info(node), _menu_path_info(node), - textwrap.indent(node.custom_str(_name_and_val_str), " ")) + _indent(node.custom_str(_name_and_val_str), 2)) return s @@ -2788,6 +2787,13 @@ def _menu_path_info(node): return "(Top)" + path +def _indent(s, n): + # Returns 's' with each line indented 'n' spaces. textwrap.indent() is not + # available in Python 2 (it's 3.3+). + + return "\n".join(n*" " + line for line in s.split("\n")) + + def _name_and_val_str(sc): # Custom symbol/choice printer that shows symbol values after symbols -- cgit v1.2.3