Skip to content

Commit 9d9eb04

Browse files
committed
rm duplicate code from fb tornado
1 parent 171d87b commit 9d9eb04

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

tmuxp/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ def main():
370370
args = parser.parse_args()
371371

372372
setupLogger(level=args.log_level.upper())
373+
logger.error('hi')
373374
try:
374375
util.version()
375376
except Exception as e:

tmuxp/log.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from colorama import init
2424
init()
2525
from colorama import Fore, Back, Style
26+
from .util import unicode, bytes, basestring
2627

2728
try:
2829
import curses
@@ -37,22 +38,8 @@
3738
# literal non-ascii characters).
3839
# todo _ can remove this, this next 10 lines is from
3940
# http://www.rfk.id.au/blog/entry/preparing-pyenchant-for-python-3/
40-
if not isinstance('', type(b'')):
41-
def u(s):
42-
return s
43-
bytes_type = bytes
44-
unicode_type = str
45-
basestring_type = str
46-
else:
47-
def u(s):
48-
return s.decode('unicode_escape')
49-
bytes_type = str
50-
unicode_type = unicode
51-
basestring_type = basestring
52-
53-
54-
_UTF8_TYPES = (bytes_type, type(None))
55-
_TO_UNICODE_TYPES = (unicode_type, type(None))
41+
_UTF8_TYPES = (bytes, type(None))
42+
_TO_UNICODE_TYPES = (unicode, type(None))
5643

5744

5845
def utf8(value):
@@ -63,7 +50,7 @@ def utf8(value):
6350
"""
6451
if isinstance(value, _UTF8_TYPES):
6552
return value
66-
assert isinstance(value, unicode_type), \
53+
assert isinstance(value, unicode), \
6754
"Expected bytes, unicode, or None; got %r" % type(value)
6855
return value.encode("utf-8")
6956

@@ -76,7 +63,7 @@ def to_unicode(value):
7663
"""
7764
if isinstance(value, _TO_UNICODE_TYPES):
7865
return value
79-
assert isinstance(value, bytes_type), \
66+
assert isinstance(value, bytes), \
8067
"Expected bytes, unicode, or None; got %r" % type(value)
8168
return value.decode("utf-8")
8269

@@ -86,7 +73,7 @@ def to_unicode(value):
8673

8774
# When dealing with the standard library across python 2 and 3 it is
8875
# sometimes useful to have a direct conversion to the native string type
89-
if str is unicode_type:
76+
if str is unicode:
9077
native_str = to_unicode
9178
else:
9279
native_str = utf8
@@ -181,7 +168,7 @@ def format(self, record):
181168
except Exception as e:
182169
record.message = "Bad message (%r): %r" % (e, record.__dict__)
183170
assert isinstance(
184-
record.message, basestring_type) # guaranteed by logging
171+
record.message, basestring) # guaranteed by logging
185172

186173
date_format = '%H:%m:%S'
187174
record.asctime = time.strftime(date_format, self.converter(record.created))

0 commit comments

Comments
 (0)