From 1871f0d1b9b3955f52ed541b716662f77e72a0d1 Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Fri, 9 Jun 2017 10:46:51 -0700 Subject: [PATCH 1/2] Deduplicate code using textwrap.fill. --- certbot/display/util.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/certbot/display/util.py b/certbot/display/util.py index 5b01dd8d4..df80789d7 100644 --- a/certbot/display/util.py +++ b/certbot/display/util.py @@ -176,12 +176,8 @@ class FileDisplay(object): if self._return_default(message, default, cli_flag, force_interactive): return OK, default - ans = input_with_timeout( - textwrap.fill( - "%s (Enter 'c' to cancel): " % message, - 80, - break_long_words=False, - break_on_hyphens=False)) + message = _wrap_lines("%s (Enter 'c' to cancel): " % message) + ans = input_with_timeout(message) if ans == "c" or ans == "C": return CANCEL, "-1" @@ -392,12 +388,8 @@ class FileDisplay(object): # Write out the menu choices for i, desc in enumerate(choices, 1): - self.outfile.write( - textwrap.fill( - "{num}: {desc}".format(num=i, desc=desc), - 80, - break_long_words=False, - break_on_hyphens=False)) + msg = "{num}: {desc}".format(num=i, desc=desc) + self.outfile.write(_wrap_lines(msg)) # Keep this outside of the textwrap self.outfile.write(os.linesep) From 2ebd8e976344a93bca11e1aae63a93f11366fc66 Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Fri, 9 Jun 2017 10:50:21 -0700 Subject: [PATCH 2/2] Add trailing space to prompt. --- certbot/display/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/certbot/display/util.py b/certbot/display/util.py index df80789d7..f1922ebb9 100644 --- a/certbot/display/util.py +++ b/certbot/display/util.py @@ -176,7 +176,8 @@ class FileDisplay(object): if self._return_default(message, default, cli_flag, force_interactive): return OK, default - message = _wrap_lines("%s (Enter 'c' to cancel): " % message) + # Trailing space must be added outside of _wrap_lines to be preserved + message = _wrap_lines("%s (Enter 'c' to cancel):" % message) + " " ans = input_with_timeout(message) if ans == "c" or ans == "C":