Replace unicode() with u() in theme.py

Fixes #271
This commit is contained in:
ZyX 2013-02-27 00:14:24 +04:00
parent a4b7c31bc3
commit 83f4236a2c
1 changed files with 10 additions and 3 deletions

View File

@ -6,11 +6,18 @@ from .segment import gen_segment_getter
try:
unicode() # NOQA
except NameError:
from __builtin__ import unicode
except ImportError:
unicode = str
def u(s):
if type(s) is unicode:
return s
else:
return unicode(s, 'utf-8')
def requires_segment_info(func):
func.requires_powerline_segment_info = True
return func
@ -82,7 +89,7 @@ class Theme(object):
else:
continue
for segment in parsed_segments:
segment['contents'] = segment['before'] + unicode(segment['contents'] if segment['contents'] is not None else '') + segment['after']
segment['contents'] = segment['before'] + u(segment['contents'] if segment['contents'] is not None else '') + segment['after']
# Align segment contents
if segment['width'] and segment['width'] != 'auto':
if segment['align'] == 'l':