Add support for python-3.2
This commit is contained in:
parent
de33eb8140
commit
9fd63021f0
|
@ -3,6 +3,12 @@
|
|||
from powerline.theme import Theme
|
||||
|
||||
|
||||
try:
|
||||
NBSP = unicode(' ', 'utf-8')
|
||||
except NameError:
|
||||
NBSP = ' '
|
||||
|
||||
|
||||
class Renderer(object):
|
||||
def __init__(self, theme_config, local_themes, theme_kwargs, colorscheme, **options):
|
||||
self.__dict__.update(options)
|
||||
|
@ -58,7 +64,7 @@ class Renderer(object):
|
|||
|
||||
if not width:
|
||||
# No width specified, so we don't need to crop or pad anything
|
||||
return self._returned_value(u''.join([segment['_rendered_hl'] for segment in segments]) + self.hlstyle(), segments, output_raw)
|
||||
return self._returned_value(''.join([segment['_rendered_hl'] for segment in segments]) + self.hlstyle(), segments, output_raw)
|
||||
|
||||
# Create an ordered list of segments that can be dropped
|
||||
segments_priority = [segment for segment in sorted(segments, key=lambda segment: segment['priority'], reverse=True) if segment['priority'] > 0]
|
||||
|
@ -81,7 +87,7 @@ class Renderer(object):
|
|||
segment['_space_right'] += space_side
|
||||
segments_spacers[0]['_space_right'] += distribute_len_remainder
|
||||
|
||||
rendered_highlighted = u''.join([segment['_rendered_hl'] for segment in self._render_segments(theme, segments)]) + self.hlstyle()
|
||||
rendered_highlighted = ''.join([segment['_rendered_hl'] for segment in self._render_segments(theme, segments)]) + self.hlstyle()
|
||||
|
||||
return self._returned_value(rendered_highlighted, segments, output_raw)
|
||||
|
||||
|
@ -99,8 +105,8 @@ class Renderer(object):
|
|||
segments_len = len(segments)
|
||||
|
||||
for index, segment in enumerate(segments):
|
||||
segment['_rendered_raw'] = u''
|
||||
segment['_rendered_hl'] = u''
|
||||
segment['_rendered_raw'] = ''
|
||||
segment['_rendered_hl'] = ''
|
||||
|
||||
prev_segment = segments[index - 1] if index > 0 else theme.EMPTY_SEGMENT
|
||||
next_segment = segments[index + 1] if index < segments_len - 1 else theme.EMPTY_SEGMENT
|
||||
|
@ -127,8 +133,8 @@ class Renderer(object):
|
|||
contents_raw = (segment['_space_left'] * ' ') + contents_raw + (segment['_space_right'] * ' ') + outer_padding
|
||||
|
||||
# Replace spaces with no-break spaces
|
||||
contents_raw = contents_raw.replace(' ', u'\u00a0')
|
||||
divider_raw = divider_raw.replace(' ', u'\u00a0')
|
||||
contents_raw = contents_raw.replace(' ', NBSP)
|
||||
divider_raw = divider_raw.replace(' ', NBSP)
|
||||
|
||||
# Apply highlighting to padded dividers and contents
|
||||
if render_highlighted:
|
||||
|
@ -182,4 +188,4 @@ class Renderer(object):
|
|||
raise NotImplementedError
|
||||
|
||||
def hl(self, contents, fg=None, bg=None, attr=None):
|
||||
return self.hlstyle(fg, bg, attr) + (contents or u'')
|
||||
return self.hlstyle(fg, bg, attr) + (contents or '')
|
||||
|
|
|
@ -79,8 +79,8 @@ def gen_segment_getter(ext, path, theme_configs, default_module=None):
|
|||
'include_modes': segment.get('include_modes', []),
|
||||
'width': segment.get('width'),
|
||||
'align': segment.get('align', 'l'),
|
||||
'_rendered_raw': u'',
|
||||
'_rendered_hl': u'',
|
||||
'_rendered_raw': '',
|
||||
'_rendered_hl': '',
|
||||
'_len': 0,
|
||||
'_space_left': 0,
|
||||
'_space_right': 0,
|
||||
|
|
|
@ -74,7 +74,7 @@ def cwd(dir_shorten_len=None, dir_limit_depth=None):
|
|||
cwd_split_len = len(cwd_split)
|
||||
if dir_limit_depth and cwd_split_len > dir_limit_depth + 1:
|
||||
del(cwd_split[0:-dir_limit_depth])
|
||||
cwd_split.insert(0, u'⋯')
|
||||
cwd_split.insert(0, '⋯')
|
||||
cwd = [i[0:dir_shorten_len] if dir_shorten_len and i else i for i in cwd_split[:-1]] + [cwd_split[-1]]
|
||||
ret = []
|
||||
if not cwd[0]:
|
||||
|
@ -263,18 +263,18 @@ weather_conditions_codes = (
|
|||
# ('sunny', (32, 36)),
|
||||
# ('night', (31, 33))):
|
||||
weather_conditions_icons = {
|
||||
'day': u'〇',
|
||||
'blustery': u'⚑',
|
||||
'rainy': u'☔',
|
||||
'cloudy': u'☁',
|
||||
'snowy': u'❅',
|
||||
'stormy': u'☈',
|
||||
'foggy': u'〰',
|
||||
'sunny': u'☼',
|
||||
'night': u'☾',
|
||||
'windy': u'☴',
|
||||
'not_available': u'<EFBFBD>',
|
||||
'unknown': u'⚠',
|
||||
'day': '〇',
|
||||
'blustery': '⚑',
|
||||
'rainy': '☔',
|
||||
'cloudy': '☁',
|
||||
'snowy': '❅',
|
||||
'stormy': '☈',
|
||||
'foggy': '〰',
|
||||
'sunny': '☼',
|
||||
'night': '☾',
|
||||
'windy': '☴',
|
||||
'not_available': '<EFBFBD>',
|
||||
'unknown': '⚠',
|
||||
}
|
||||
|
||||
|
||||
|
@ -306,8 +306,8 @@ def weather(unit='c', location_query=None, icons=None):
|
|||
return None
|
||||
query_data = {
|
||||
'q':
|
||||
u'use "http://github.com/yql/yql-tables/raw/master/weather/weather.bylocation.xml" as we;'
|
||||
u'select * from we where location="{0}" and unit="{1}"'.format(location_query, unit).encode('utf-8'),
|
||||
'use "http://github.com/yql/yql-tables/raw/master/weather/weather.bylocation.xml" as we;'
|
||||
'select * from we where location="{0}" and unit="{1}"'.format(location_query, unit).encode('utf-8'),
|
||||
'format': 'json'
|
||||
}
|
||||
try:
|
||||
|
@ -339,7 +339,7 @@ def weather(unit='c', location_query=None, icons=None):
|
|||
'divider_highlight_group': 'background:divider',
|
||||
},
|
||||
{
|
||||
'contents': u'{0}°{1}'.format(condition['temp'], unit.upper()),
|
||||
'contents': '{0}°{1}'.format(condition['temp'], unit.upper()),
|
||||
'highlight_group': ['weather_temp_cold' if int(condition['temp']) < 0 else 'weather_temp_hot', 'weather_temp', 'weather'],
|
||||
'draw_divider': False,
|
||||
'divider_highlight_group': 'background:divider',
|
||||
|
@ -397,7 +397,7 @@ def cpu_load_percent(measure_interval=.5):
|
|||
except ImportError:
|
||||
return None
|
||||
cpu_percent = int(psutil.cpu_percent(interval=measure_interval))
|
||||
return u'{0}%'.format(cpu_percent)
|
||||
return '{0}%'.format(cpu_percent)
|
||||
|
||||
|
||||
@add_divider_highlight_group('background:divider')
|
||||
|
@ -443,7 +443,7 @@ def network_load(interface='eth0', measure_interval=1, suffix='B/s', si_prefix=F
|
|||
return None
|
||||
time.sleep(measure_interval)
|
||||
b2 = get_bytes()
|
||||
return u'⬇ {rx_diff} ⬆ {tx_diff}'.format(
|
||||
return '⬇ {rx_diff} ⬆ {tx_diff}'.format(
|
||||
rx_diff=humanize_bytes((b2[0] - b1[0]) / measure_interval, suffix, si_prefix).rjust(8),
|
||||
tx_diff=humanize_bytes((b2[1] - b1[1]) / measure_interval, suffix, si_prefix).rjust(8),
|
||||
)
|
||||
|
@ -492,13 +492,13 @@ def email_imap_alert(username, password, server='imap.gmail.com', port=993, fold
|
|||
|
||||
class NowPlayingSegment(object):
|
||||
STATE_SYMBOLS = {
|
||||
'fallback': u'♫',
|
||||
'play': u'▶',
|
||||
'pause': u'▮▮',
|
||||
'stop': u'■',
|
||||
'fallback': '♫',
|
||||
'play': '▶',
|
||||
'pause': '▮▮',
|
||||
'stop': '■',
|
||||
}
|
||||
|
||||
def __call__(self, player='mpd', format=u'{state_symbol} {artist} - {title} ({total})', *args, **kwargs):
|
||||
def __call__(self, player='mpd', format='{state_symbol} {artist} - {title} ({total})', *args, **kwargs):
|
||||
player_func = getattr(self, 'player_{0}'.format(player))
|
||||
stats = {
|
||||
'state': None,
|
||||
|
@ -538,7 +538,7 @@ class NowPlayingSegment(object):
|
|||
|
||||
@staticmethod
|
||||
def _convert_seconds(seconds):
|
||||
return u'{0:.0f}:{1:02.0f}'.format(*divmod(float(seconds), 60))
|
||||
return '{0:.0f}:{1:02.0f}'.format(*divmod(float(seconds), 60))
|
||||
|
||||
def player_cmus(self):
|
||||
'''Return cmus player information.
|
||||
|
|
|
@ -22,24 +22,24 @@ vim_funcs = {
|
|||
}
|
||||
|
||||
vim_modes = {
|
||||
'n': u'NORMAL',
|
||||
'no': u'N·OPER',
|
||||
'v': u'VISUAL',
|
||||
'V': u'V·LINE',
|
||||
'^V': u'V·BLCK',
|
||||
's': u'SELECT',
|
||||
'S': u'S·LINE',
|
||||
'^S': u'S·BLCK',
|
||||
'i': u'INSERT',
|
||||
'R': u'REPLACE',
|
||||
'Rv': u'V·RPLCE',
|
||||
'c': u'COMMND',
|
||||
'cv': u'VIM EX',
|
||||
'ce': u'EX',
|
||||
'r': u'PROMPT',
|
||||
'rm': u'MORE',
|
||||
'r?': u'CONFIRM',
|
||||
'!': u'SHELL',
|
||||
'n': 'NORMAL',
|
||||
'no': 'N·OPER',
|
||||
'v': 'VISUAL',
|
||||
'V': 'V·LINE',
|
||||
'^V': 'V·BLCK',
|
||||
's': 'SELECT',
|
||||
'S': 'S·LINE',
|
||||
'^S': 'S·BLCK',
|
||||
'i': 'INSERT',
|
||||
'R': 'REPLACE',
|
||||
'Rv': 'V·RPLCE',
|
||||
'c': 'COMMND',
|
||||
'cv': 'VIM EX',
|
||||
'ce': 'EX',
|
||||
'r': 'PROMPT',
|
||||
'rm': 'MORE',
|
||||
'r?': 'CONFIRM',
|
||||
'!': 'SHELL',
|
||||
}
|
||||
|
||||
|
||||
|
@ -119,7 +119,7 @@ def mode(segment_info, override=None):
|
|||
|
||||
|
||||
@requires_segment_info
|
||||
def modified_indicator(segment_info, text=u'+'):
|
||||
def modified_indicator(segment_info, text='+'):
|
||||
'''Return a file modified indicator.
|
||||
|
||||
:param string text:
|
||||
|
@ -139,7 +139,7 @@ def paste_indicator(segment_info, text='PASTE'):
|
|||
|
||||
|
||||
@requires_segment_info
|
||||
def readonly_indicator(segment_info, text=u''):
|
||||
def readonly_indicator(segment_info, text=''):
|
||||
'''Return a read-only indicator.
|
||||
|
||||
:param string text:
|
||||
|
@ -274,7 +274,7 @@ def virtcol_current():
|
|||
'highlight_group': ['virtcol_current', 'col_current']}]
|
||||
|
||||
|
||||
def modified_buffers(text=u'+ ', join_str=u','):
|
||||
def modified_buffers(text='+ ', join_str=','):
|
||||
'''Return a comma-separated list of modified buffers.
|
||||
|
||||
:param str text:
|
||||
|
|
|
@ -8,7 +8,7 @@ from .segment import gen_segment_getter
|
|||
try:
|
||||
from __builtin__ import unicode
|
||||
except ImportError:
|
||||
unicode = str
|
||||
unicode = str # NOQA
|
||||
|
||||
|
||||
def u(s):
|
||||
|
|
Loading…
Reference in New Issue