aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-09-06 19:01:07 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-09-06 19:01:07 -0700
commitf6fe3df59b3a9345879661c3be12ecf44a2f2ed2 (patch)
tree9525247f897f50938723f77a9827a97fd62985c4
parente0764bb25efa65ceef4f5164fb69324a9714eff1 (diff)
Fix to make prompt chooser work in Python3
-rwxr-xr-xshare/tools/web_config/webconfig.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py
index 7b33664c..a90b07a2 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('</span>')
+
+ # 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] == '</span>' and result[idx-1].startswith('<span'):
+ # Empty span, delete these two
+ result[idx-1:idx+1] = []
+ idx = idx - 1
+
return ''.join(result)
class FishVar: