summaryrefslogtreecommitdiffstats
path: root/utils/lit
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2013-08-21 22:26:47 +0000
committerDaniel Dunbar <daniel@zuster.org>2013-08-21 22:26:47 +0000
commit4db169d31e34df89d10660960070de073f0f28af (patch)
treeee748219ca8ce05321dbf460fdd6c78d31aa7b66 /utils/lit
parent51a0b77cbfadb523c01cc787dea5ab7f2f296867 (diff)
downloadexternal_llvm-4db169d31e34df89d10660960070de073f0f28af.zip
external_llvm-4db169d31e34df89d10660960070de073f0f28af.tar.gz
external_llvm-4db169d31e34df89d10660960070de073f0f28af.tar.bz2
[lit] Fix a couple lingering Py3 compat issues in ProgressBar.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188951 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/lit')
-rw-r--r--utils/lit/lit/ProgressBar.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/utils/lit/lit/ProgressBar.py b/utils/lit/lit/ProgressBar.py
index 8b9b81e..e3644f1 100644
--- a/utils/lit/lit/ProgressBar.py
+++ b/utils/lit/lit/ProgressBar.py
@@ -5,6 +5,10 @@
import sys, re, time
+def to_bytes(str):
+ # Encode to Latin1 to get binary data.
+ return str.encode('ISO-8859-1')
+
class TerminalController:
"""
A class that can be used to portably generate formatted output to
@@ -116,19 +120,23 @@ class TerminalController:
set_fg = self._tigetstr('setf')
if set_fg:
for i,color in zip(range(len(self._COLORS)), self._COLORS):
- setattr(self, color, curses.tparm(set_fg, i) or '')
+ setattr(self, color, self._tparm(set_fg, i))
set_fg_ansi = self._tigetstr('setaf')
if set_fg_ansi:
for i,color in zip(range(len(self._ANSICOLORS)), self._ANSICOLORS):
- setattr(self, color, curses.tparm(set_fg_ansi, i) or '')
+ setattr(self, color, self._tparm(set_fg_ansi, i))
set_bg = self._tigetstr('setb')
if set_bg:
for i,color in zip(range(len(self._COLORS)), self._COLORS):
- setattr(self, 'BG_'+color, curses.tparm(set_bg, i) or '')
+ setattr(self, 'BG_'+color, self._tparm(set_bg, i))
set_bg_ansi = self._tigetstr('setab')
if set_bg_ansi:
for i,color in zip(range(len(self._ANSICOLORS)), self._ANSICOLORS):
- setattr(self, 'BG_'+color, curses.tparm(set_bg_ansi, i) or '')
+ setattr(self, 'BG_'+color, self._tparm(set_bg_ansi, i))
+
+ def _tparm(self, arg, index):
+ import curses
+ return curses.tparm(to_bytes(arg), index).decode('ascii') or ''
def _tigetstr(self, cap_name):
# String capabilities can include "delays" of the form "$<2>".