From f6fe3df59b3a9345879661c3be12ecf44a2f2ed2 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Thu, 6 Sep 2012 19:01:07 -0700 Subject: [PATCH] Fix to make prompt chooser work in Python3 --- share/tools/web_config/webconfig.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 7b33664cf..a90b07a20 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -118,6 +118,7 @@ def get_special_ansi_escapes(): val = None key = curses.tigetstr("sgr0") if key: val = curses.tparm(key) + if val: val = val.decode('utf-8') return val # Just a few for now @@ -186,9 +187,9 @@ def ansi_to_html(val): # Hence this lame check separated = re.split(""" ( # Capture - \x1b # Escpae - [^m]+ # One or more non-'m's - m # Literal m terminates the sequence + \x1b # Escape + [^m]+ # One or more non-'m's + m # Literal m terminates the sequence ) # End capture """, val, 0, re.VERBOSE) @@ -211,6 +212,18 @@ def ansi_to_html(val): # Close final escape if span_open: result.append('') + + # Remove empty elements + result = [x for x in result if x] + + # Clean up empty spans, the nasty way + idx = len(result) - 1 + while idx >= 1: + if result[idx] == '' and result[idx-1].startswith('