Skip to content

Commit cb7e469

Browse files
committed
Fix issue #43
1 parent d0dd84f commit cb7e469

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

werobot/logger.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding:utf-8 -*-
22

3+
import six
34
import sys
45
import time
56
import logging
@@ -38,28 +39,21 @@ def __init__(self, color, *args, **kwargs):
3839
logging.Formatter.__init__(self, *args, **kwargs)
3940
self._color = color
4041
if color:
41-
# The curses module has some str/bytes confusion in
42-
# python3. Until version 3.2.3, most methods return
43-
# bytes, but only accept strings. In addition, we want to
44-
# output these strings with the logging module, which
45-
# works with unicode strings. The explicit calls to
46-
# unicode() below are harmless in python2 but will do the
47-
# right conversion in python 3.
4842
fg_color = (curses.tigetstr("setaf") or
4943
curses.tigetstr("setf") or "")
5044
if (3, 0) < sys.version_info < (3, 2, 3):
51-
fg_color = unicode(fg_color, "ascii")
45+
fg_color = six.text_type(fg_color, "ascii")
5246
self._colors = {
53-
logging.DEBUG: unicode(curses.tparm(fg_color, 4),
47+
logging.DEBUG: six.text_type(curses.tparm(fg_color, 4),
5448
"ascii"), # Blue
55-
logging.INFO: unicode(curses.tparm(fg_color, 2),
49+
logging.INFO: six.text_type(curses.tparm(fg_color, 2),
5650
"ascii"), # Green
57-
logging.WARNING: unicode(curses.tparm(fg_color, 3),
51+
logging.WARNING: six.text_type(curses.tparm(fg_color, 3),
5852
"ascii"), # Yellow
59-
logging.ERROR: unicode(curses.tparm(fg_color, 1),
53+
logging.ERROR: six.text_type(curses.tparm(fg_color, 1),
6054
"ascii"), # Red
6155
}
62-
self._normal = unicode(curses.tigetstr("sgr0"), "ascii")
56+
self._normal = six.text_type(curses.tigetstr("sgr0"), "ascii")
6357

6458
def format(self, record):
6559
try:

0 commit comments

Comments
 (0)