Merge branch 'fix-788' into develop

This commit is contained in:
ZyX 2014-02-08 23:43:49 +04:00
commit 173159aea4
3 changed files with 33 additions and 31 deletions

13
powerline/lib/unicode.py Normal file
View File

@ -0,0 +1,13 @@
# vim:fileencoding=utf-8:noet
try:
from __builtin__ import unicode
except ImportError:
unicode = str # NOQA
def u(s):
if type(s) is unicode:
return s
else:
return unicode(s, 'utf-8')

View File

@ -17,6 +17,7 @@ from powerline.lib.vcs import guess, tree_status
from powerline.lib.threaded import ThreadedSegment, KwThreadedSegment, with_docstring
from powerline.lib.monotonic import monotonic
from powerline.lib.humanize_bytes import humanize_bytes
from powerline.lib.unicode import u
from powerline.theme import requires_segment_info
from collections import namedtuple
@ -91,7 +92,7 @@ def cwd(pl, segment_info, dir_shorten_len=None, dir_limit_depth=None, use_path_s
Highlight groups used: ``cwd:current_folder`` or ``cwd``. It is recommended to define all highlight groups.
'''
try:
cwd = segment_info['getcwd']()
cwd = u(segment_info['getcwd']())
except OSError as e:
if e.errno == 2:
# user most probably deleted the directory
@ -100,7 +101,7 @@ def cwd(pl, segment_info, dir_shorten_len=None, dir_limit_depth=None, use_path_s
cwd = "[not found]"
else:
raise
home = segment_info['home']
home = u(segment_info['home'])
if home:
cwd = re.sub('^' + re.escape(home), '~', cwd, 1)
cwd_split = cwd.split(os.sep)

View File

@ -1,19 +1,7 @@
# vim:fileencoding=utf-8:noet
from .segment import gen_segment_getter
try:
from __builtin__ import unicode
except ImportError:
unicode = str # NOQA
def u(s):
if type(s) is unicode:
return s
else:
return unicode(s, 'utf-8')
from powerline.segment import gen_segment_getter
from powerline.lib.unicode import u, unicode
def requires_segment_info(func):