summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2019-06-06 09:24:51 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2019-06-06 09:24:51 +0200
commit443e6bb8efd41f1e4bb42e1efdb37e9c3e22dc67 (patch)
tree62d2c6bd0ede1b23f0035731c16f06ddd21a57c6
parent2f624667bc130a8becd65fabed62c3fdc9bda005 (diff)
menuconfig: Fix help display on Python 2
textwrap.indent() was added in Python 3.3.
-rwxr-xr-xmenuconfig.py12
1 files changed, 9 insertions, 3 deletions
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