Change indentation of closing }, ], ) and combinations of them

This commit is contained in:
ZyX 2013-03-25 19:04:18 +04:00
parent ada5dede25
commit 27c9a05782
7 changed files with 62 additions and 62 deletions

View File

@ -187,7 +187,7 @@ class Powerline(object):
'ext': self.ext, 'ext': self.ext,
'common_config': self.common_config, 'common_config': self.common_config,
'run_once': self.run_once, 'run_once': self.run_once,
} }
self.ext_config = config['ext'][self.ext] self.ext_config = config['ext'][self.ext]
if self.ext_config != self.prev_ext_config: if self.ext_config != self.prev_ext_config:

View File

@ -109,7 +109,7 @@ class Colorscheme(object):
'fg': pick_color(group_props['fg']), 'fg': pick_color(group_props['fg']),
'bg': pick_color(group_props['bg']), 'bg': pick_color(group_props['bg']),
'attr': get_attr_flag(group_props.get('attr', [])), 'attr': get_attr_flag(group_props.get('attr', [])),
} }
# 0 1 2 3 4 5 6 7 8 9 # 0 1 2 3 4 5 6 7 8 9

View File

@ -83,7 +83,7 @@ class BranchSegment(RepositorySegment):
return [{ return [{
'contents': branch, 'contents': branch,
'highlight_group': ['branch_dirty' if repository_status(**kwargs) else 'branch_clean', 'branch'], 'highlight_group': ['branch_dirty' if repository_status(**kwargs) else 'branch_clean', 'branch'],
}] }]
else: else:
return branch return branch
@ -153,7 +153,7 @@ def cwd(pl, dir_shorten_len=None, dir_limit_depth=None):
ret.append({ ret.append({
'contents': part, 'contents': part,
'divider_highlight_group': 'cwd:divider', 'divider_highlight_group': 'cwd:divider',
}) })
ret[-1]['highlight_group'] = ['cwd:current_folder', 'cwd'] ret[-1]['highlight_group'] = ['cwd:current_folder', 'cwd']
return ret return ret
@ -190,7 +190,7 @@ def fuzzy_time(pl):
45: 'quarter to', 45: 'quarter to',
50: 'ten to', 50: 'ten to',
55: 'five to', 55: 'five to',
} }
special_case_str = { special_case_str = {
(23, 58): 'round about midnight', (23, 58): 'round about midnight',
(23, 59): 'round about midnight', (23, 59): 'round about midnight',
@ -198,7 +198,7 @@ def fuzzy_time(pl):
(0, 1): 'round about midnight', (0, 1): 'round about midnight',
(0, 2): 'round about midnight', (0, 2): 'round about midnight',
(12, 0): 'noon', (12, 0): 'noon',
} }
now = datetime.now() now = datetime.now()
@ -337,17 +337,17 @@ weather_conditions_icons = {
} }
temp_conversions = { temp_conversions = {
'C': lambda temp: temp, 'C': lambda temp: temp,
'F': lambda temp: (temp * 9 / 5) + 32, 'F': lambda temp: (temp * 9 / 5) + 32,
'K': lambda temp: temp + 273.15, 'K': lambda temp: temp + 273.15,
} }
# Note: there are also unicode characters for units: ℃, ℉ and # Note: there are also unicode characters for units: ℃, ℉ and
temp_units = { temp_units = {
'C': '°C', 'C': '°C',
'F': '°F', 'F': '°F',
'K': 'K', 'K': 'K',
} }
class WeatherSegment(ThreadedSegment): class WeatherSegment(ThreadedSegment):
@ -371,11 +371,11 @@ class WeatherSegment(ThreadedSegment):
location_data['region_name'], location_data['region_name'],
location_data['country_name']]) location_data['country_name']])
query_data = { query_data = {
'q': 'q':
'use "http://github.com/yql/yql-tables/raw/master/weather/weather.bylocation.xml" as we;' 'use "http://github.com/yql/yql-tables/raw/master/weather/weather.bylocation.xml" as we;'
'select * from we where location="{0}" and unit="c"'.format(self.location).encode('utf-8'), 'select * from we where location="{0}" and unit="c"'.format(self.location).encode('utf-8'),
'format': 'json', 'format': 'json',
} }
self.url = 'http://query.yahooapis.com/v1/public/yql?' + urllib_urlencode(query_data) self.url = 'http://query.yahooapis.com/v1/public/yql?' + urllib_urlencode(query_data)
raw_response = urllib_read(self.url) raw_response = urllib_read(self.url)
@ -423,19 +423,19 @@ class WeatherSegment(ThreadedSegment):
gradient_level = (self.temp - temp_coldest) * 100.0 / (temp_hottest - temp_coldest) gradient_level = (self.temp - temp_coldest) * 100.0 / (temp_hottest - temp_coldest)
groups = ['weather_condition_' + icon_name for icon_name in self.icon_names] + ['weather_conditions', 'weather'] groups = ['weather_condition_' + icon_name for icon_name in self.icon_names] + ['weather_conditions', 'weather']
return [ return [
{ {
'contents': icon + ' ', 'contents': icon + ' ',
'highlight_group': groups, 'highlight_group': groups,
'divider_highlight_group': 'background:divider', 'divider_highlight_group': 'background:divider',
}, },
{ {
'contents': temp_format.format(temp=temp), 'contents': temp_format.format(temp=temp),
'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'],
'draw_divider': False, 'draw_divider': False,
'divider_highlight_group': 'background:divider', 'divider_highlight_group': 'background:divider',
'gradient_level': gradient_level, 'gradient_level': gradient_level,
}, },
] ]
weather = with_docstring(WeatherSegment(), weather = with_docstring(WeatherSegment(),
@ -517,7 +517,7 @@ def system_load(pl, format='{avg:.1f}', threshold_good=1, threshold_bad=2):
'draw_divider': False, 'draw_divider': False,
'divider_highlight_group': 'background:divider', 'divider_highlight_group': 'background:divider',
'gradient_level': gradient_level, 'gradient_level': gradient_level,
}) })
ret[0]['draw_divider'] = True ret[0]['draw_divider'] = True
ret[0]['contents'] += ' ' ret[0]['contents'] += ' '
ret[1]['contents'] += ' ' ret[1]['contents'] += ' '
@ -602,9 +602,9 @@ def user(pl):
return None return None
euid = _geteuid() euid = _geteuid()
return [{ return [{
'contents': username, 'contents': username,
'highlight_group': 'user' if euid != 0 else ['superuser', 'user'], 'highlight_group': 'user' if euid != 0 else ['superuser', 'user'],
}] }]
if os.path.exists('/proc/uptime'): if os.path.exists('/proc/uptime'):
@ -724,7 +724,7 @@ class NetworkLoadSegment(KwThreadedSegment):
'contents': format.format(value=humanize_bytes(value, suffix, si_prefix)), 'contents': format.format(value=humanize_bytes(value, suffix, si_prefix)),
'divider_highlight_group': 'background:divider', 'divider_highlight_group': 'background:divider',
'highlight_group': hl_groups, 'highlight_group': hl_groups,
}) })
if is_gradient: if is_gradient:
max = kwargs[max_key] max = kwargs[max_key]
if value >= max: if value >= max:
@ -804,13 +804,13 @@ class EmailIMAPSegment(KwThreadedSegment):
return [{ return [{
'contents': str(unread_count), 'contents': str(unread_count),
'highlight_group': 'email_alert', 'highlight_group': 'email_alert',
}] }]
else: else:
return [{ return [{
'contents': str(unread_count), 'contents': str(unread_count),
'highlight_group': ['email_alert_gradient', 'email_alert'], 'highlight_group': ['email_alert_gradient', 'email_alert'],
'gradient_level': unread_count * 100.0 / max_msgs, 'gradient_level': unread_count * 100.0 / max_msgs,
}] }]
email_imap_alert = with_docstring(EmailIMAPSegment(), email_imap_alert = with_docstring(EmailIMAPSegment(),
@ -841,7 +841,7 @@ class NowPlayingSegment(object):
'play': '', 'play': '',
'pause': '▮▮', 'pause': '▮▮',
'stop': '', 'stop': '',
} }
def __call__(self, player='mpd', format='{state_symbol} {artist} - {title} ({total})', **kwargs): def __call__(self, player='mpd', format='{state_symbol} {artist} - {title} ({total})', **kwargs):
player_func = getattr(self, 'player_{0}'.format(player)) player_func = getattr(self, 'player_{0}'.format(player))
@ -853,7 +853,7 @@ class NowPlayingSegment(object):
'title': None, 'title': None,
'elapsed': None, 'elapsed': None,
'total': None, 'total': None,
} }
func_stats = player_func(**kwargs) func_stats = player_func(**kwargs)
if not func_stats: if not func_stats:
return None return None
@ -921,7 +921,7 @@ class NowPlayingSegment(object):
'title': now_playing.get('title'), 'title': now_playing.get('title'),
'elapsed': self._convert_seconds(now_playing.get('position', 0)), 'elapsed': self._convert_seconds(now_playing.get('position', 0)),
'total': self._convert_seconds(now_playing.get('duration', 0)), 'total': self._convert_seconds(now_playing.get('duration', 0)),
} }
def player_mpd(self, pl, host='localhost', port=6600): def player_mpd(self, pl, host='localhost', port=6600):
try: try:
@ -942,7 +942,7 @@ class NowPlayingSegment(object):
'title': now_playing.get('title'), 'title': now_playing.get('title'),
'elapsed': self._convert_seconds(now_playing.get('elapsed', 0)), 'elapsed': self._convert_seconds(now_playing.get('elapsed', 0)),
'total': self._convert_seconds(now_playing.get('time', 0)), 'total': self._convert_seconds(now_playing.get('time', 0)),
} }
except ImportError: except ImportError:
now_playing = self._run_cmd(['mpc', 'current', '-f', '%album%\n%artist%\n%title%\n%time%', '-h', str(host), '-p', str(port)]) now_playing = self._run_cmd(['mpc', 'current', '-f', '%album%\n%artist%\n%title%\n%time%', '-h', str(host), '-p', str(port)])
if not now_playing: if not now_playing:
@ -953,7 +953,7 @@ class NowPlayingSegment(object):
'artist': now_playing[1], 'artist': now_playing[1],
'title': now_playing[2], 'title': now_playing[2],
'total': now_playing[3], 'total': now_playing[3],
} }
def player_spotify(self, pl): def player_spotify(self, pl):
try: try:
@ -981,7 +981,7 @@ class NowPlayingSegment(object):
'artist': info.get('xesam:artist')[0], 'artist': info.get('xesam:artist')[0],
'title': info.get('xesam:title'), 'title': info.get('xesam:title'),
'total': self._convert_seconds(info.get('mpris:length') / 1e6), 'total': self._convert_seconds(info.get('mpris:length') / 1e6),
} }
def player_rhythmbox(self, pl): def player_rhythmbox(self, pl):
now_playing = self._run_cmd(['rhythmbox-client', '--no-start', '--no-present', '--print-playing-format', '%at\n%aa\n%tt\n%te\n%td']) now_playing = self._run_cmd(['rhythmbox-client', '--no-start', '--no-present', '--print-playing-format', '%at\n%aa\n%tt\n%te\n%td'])
@ -994,5 +994,5 @@ class NowPlayingSegment(object):
'title': now_playing[2], 'title': now_playing[2],
'elapsed': now_playing[3], 'elapsed': now_playing[3],
'total': now_playing[4], 'total': now_playing[4],
} }
now_playing = NowPlayingSegment() now_playing = NowPlayingSegment()

View File

@ -181,7 +181,7 @@ def file_name(pl, segment_info, display_no_file=False, no_file_text='[No file]')
return [{ return [{
'contents': no_file_text, 'contents': no_file_text,
'highlight_group': ['file_name_no_file', 'file_name'], 'highlight_group': ['file_name_no_file', 'file_name'],
}] }]
else: else:
return None return None
file_name = vim_funcs['fnamemodify'](name, ':~:.:t') file_name = vim_funcs['fnamemodify'](name, ':~:.:t')
@ -258,7 +258,7 @@ def line_percent(pl, segment_info, gradient=False):
'contents': str(int(round(percentage))), 'contents': str(int(round(percentage))),
'highlight_group': ['line_percent_gradient', 'line_percent'], 'highlight_group': ['line_percent_gradient', 'line_percent'],
'gradient_level': percentage, 'gradient_level': percentage,
}] }]
@requires_segment_info @requires_segment_info
@ -371,7 +371,7 @@ class BranchSegment(RepositorySegment):
'highlight_group': (['branch_dirty' if repository_status(segment_info=segment_info, **kwargs) else 'branch_clean'] 'highlight_group': (['branch_dirty' if repository_status(segment_info=segment_info, **kwargs) else 'branch_clean']
if status_colors else []) + ['branch'], if status_colors else []) + ['branch'],
'divider_highlight_group': 'branch:divider', 'divider_highlight_group': 'branch:divider',
}] }]
def startup(self, status_colors=False, **kwargs): def startup(self, status_colors=False, **kwargs):
super(BranchSegment, self).startup(**kwargs) super(BranchSegment, self).startup(**kwargs)
@ -422,7 +422,7 @@ class FileVCSStatusSegment(KwWindowThreadedSegment):
ret.append({ ret.append({
'contents': status, 'contents': status,
'highlight_group': ['file_vcs_status_' + status, 'file_vcs_status'], 'highlight_group': ['file_vcs_status_' + status, 'file_vcs_status'],
}) })
return ret return ret
return None return None

View File

@ -30,11 +30,11 @@ class Theme(object):
self.segments = { self.segments = {
'left': [], 'left': [],
'right': [], 'right': [],
} }
self.EMPTY_SEGMENT = { self.EMPTY_SEGMENT = {
'contents': None, 'contents': None,
'highlight': {'fg': False, 'bg': False, 'attr': 0} 'highlight': {'fg': False, 'bg': False, 'attr': 0}
} }
self.pl = pl self.pl = pl
theme_configs = [theme_config] theme_configs = [theme_config]
if top_theme_config: if top_theme_config:

View File

@ -26,7 +26,7 @@ setup(
scripts=[ scripts=[
'scripts/powerline', 'scripts/powerline',
'scripts/powerline-lint', 'scripts/powerline-lint',
], ],
keywords='', keywords='',
packages=find_packages(exclude=('tests', 'tests.*')), packages=find_packages(exclude=('tests', 'tests.*')),
include_package_data=True, include_package_data=True,
@ -35,7 +35,7 @@ setup(
extras_require={ extras_require={
'docs': [ 'docs': [
'Sphinx', 'Sphinx',
], ],
}, },
test_suite='tests' if not old_python else None, test_suite='tests' if not old_python else None,
) )

View File

@ -143,35 +143,35 @@ class TestCommon(TestCase):
self.assertEqual(common.weather(pl=pl), [ self.assertEqual(common.weather(pl=pl), [
{'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': ''}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': ''},
{'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 30.0} {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 30.0}
]) ])
self.assertEqual(common.weather(pl=pl, temp_coldest=0, temp_hottest=100), [ self.assertEqual(common.weather(pl=pl, temp_coldest=0, temp_hottest=100), [
{'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': ''}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': ''},
{'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 0} {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 0}
]) ])
self.assertEqual(common.weather(pl=pl, temp_coldest=-100, temp_hottest=-50), [ self.assertEqual(common.weather(pl=pl, temp_coldest=-100, temp_hottest=-50), [
{'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': ''}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': ''},
{'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 100} {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 100}
]) ])
self.assertEqual(common.weather(pl=pl, icons={'cloudy': 'o'}), [ self.assertEqual(common.weather(pl=pl, icons={'cloudy': 'o'}), [
{'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': 'o '}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': 'o '},
{'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 30.0} {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 30.0}
]) ])
self.assertEqual(common.weather(pl=pl, icons={'partly_cloudy_day': 'x'}), [ self.assertEqual(common.weather(pl=pl, icons={'partly_cloudy_day': 'x'}), [
{'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': 'x '}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': 'x '},
{'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 30.0} {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 30.0}
]) ])
self.assertEqual(common.weather(pl=pl, unit='F'), [ self.assertEqual(common.weather(pl=pl, unit='F'), [
{'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': ''}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': ''},
{'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '16°F', 'gradient_level': 30.0} {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '16°F', 'gradient_level': 30.0}
]) ])
self.assertEqual(common.weather(pl=pl, unit='K'), [ self.assertEqual(common.weather(pl=pl, unit='K'), [
{'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': ''}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': ''},
{'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '264K', 'gradient_level': 30.0} {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '264K', 'gradient_level': 30.0}
]) ])
self.assertEqual(common.weather(pl=pl, temp_format='{temp:.1e}C'), [ self.assertEqual(common.weather(pl=pl, temp_format='{temp:.1e}C'), [
{'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': ''}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': ''},
{'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9.0e+00C', 'gradient_level': 30.0} {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9.0e+00C', 'gradient_level': 30.0}
]) ])
def test_system_load(self): def test_system_load(self):
pl = Pl() pl = Pl()
@ -227,23 +227,23 @@ class TestCommon(TestCase):
self.assertEqual(common.network_load(pl=pl, interface='eth0'), [ self.assertEqual(common.network_load(pl=pl, interface='eth0'), [
{'divider_highlight_group': 'background:divider', 'contents': '⬇ 1 KiB/s', 'highlight_group': ['network_load_recv', 'network_load']}, {'divider_highlight_group': 'background:divider', 'contents': '⬇ 1 KiB/s', 'highlight_group': ['network_load_recv', 'network_load']},
{'divider_highlight_group': 'background:divider', 'contents': '⬆ 2 KiB/s', 'highlight_group': ['network_load_sent', 'network_load']}, {'divider_highlight_group': 'background:divider', 'contents': '⬆ 2 KiB/s', 'highlight_group': ['network_load_sent', 'network_load']},
]) ])
self.assertEqual(common.network_load(pl=pl, interface='eth0', recv_format='r {value}', sent_format='s {value}'), [ self.assertEqual(common.network_load(pl=pl, interface='eth0', recv_format='r {value}', sent_format='s {value}'), [
{'divider_highlight_group': 'background:divider', 'contents': 'r 1 KiB/s', 'highlight_group': ['network_load_recv', 'network_load']}, {'divider_highlight_group': 'background:divider', 'contents': 'r 1 KiB/s', 'highlight_group': ['network_load_recv', 'network_load']},
{'divider_highlight_group': 'background:divider', 'contents': 's 2 KiB/s', 'highlight_group': ['network_load_sent', 'network_load']}, {'divider_highlight_group': 'background:divider', 'contents': 's 2 KiB/s', 'highlight_group': ['network_load_sent', 'network_load']},
]) ])
self.assertEqual(common.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', suffix='bps', interface='eth0'), [ self.assertEqual(common.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', suffix='bps', interface='eth0'), [
{'divider_highlight_group': 'background:divider', 'contents': 'r 1 Kibps', 'highlight_group': ['network_load_recv', 'network_load']}, {'divider_highlight_group': 'background:divider', 'contents': 'r 1 Kibps', 'highlight_group': ['network_load_recv', 'network_load']},
{'divider_highlight_group': 'background:divider', 'contents': 's 2 Kibps', 'highlight_group': ['network_load_sent', 'network_load']}, {'divider_highlight_group': 'background:divider', 'contents': 's 2 Kibps', 'highlight_group': ['network_load_sent', 'network_load']},
]) ])
self.assertEqual(common.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', si_prefix=True, interface='eth0'), [ self.assertEqual(common.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', si_prefix=True, interface='eth0'), [
{'divider_highlight_group': 'background:divider', 'contents': 'r 1 kB/s', 'highlight_group': ['network_load_recv', 'network_load']}, {'divider_highlight_group': 'background:divider', 'contents': 'r 1 kB/s', 'highlight_group': ['network_load_recv', 'network_load']},
{'divider_highlight_group': 'background:divider', 'contents': 's 2 kB/s', 'highlight_group': ['network_load_sent', 'network_load']}, {'divider_highlight_group': 'background:divider', 'contents': 's 2 kB/s', 'highlight_group': ['network_load_sent', 'network_load']},
]) ])
self.assertEqual(common.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', recv_max=0, interface='eth0'), [ self.assertEqual(common.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', recv_max=0, interface='eth0'), [
{'divider_highlight_group': 'background:divider', 'contents': 'r 1 KiB/s', 'highlight_group': ['network_load_recv_gradient', 'network_load_gradient', 'network_load_recv', 'network_load'], 'gradient_level': 100}, {'divider_highlight_group': 'background:divider', 'contents': 'r 1 KiB/s', 'highlight_group': ['network_load_recv_gradient', 'network_load_gradient', 'network_load_recv', 'network_load'], 'gradient_level': 100},
{'divider_highlight_group': 'background:divider', 'contents': 's 2 KiB/s', 'highlight_group': ['network_load_sent', 'network_load']}, {'divider_highlight_group': 'background:divider', 'contents': 's 2 KiB/s', 'highlight_group': ['network_load_sent', 'network_load']},
]) ])
class ApproxEqual(object): class ApproxEqual(object):
def __eq__(self, i): def __eq__(self, i):
@ -252,7 +252,7 @@ class TestCommon(TestCase):
self.assertEqual(common.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', sent_max=4800, interface='eth0'), [ self.assertEqual(common.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', sent_max=4800, interface='eth0'), [
{'divider_highlight_group': 'background:divider', 'contents': 'r 1 KiB/s', 'highlight_group': ['network_load_recv', 'network_load']}, {'divider_highlight_group': 'background:divider', 'contents': 'r 1 KiB/s', 'highlight_group': ['network_load_recv', 'network_load']},
{'divider_highlight_group': 'background:divider', 'contents': 's 2 KiB/s', 'highlight_group': ['network_load_sent_gradient', 'network_load_gradient', 'network_load_sent', 'network_load'], 'gradient_level': ApproxEqual()}, {'divider_highlight_group': 'background:divider', 'contents': 's 2 KiB/s', 'highlight_group': ['network_load_sent_gradient', 'network_load_gradient', 'network_load_sent', 'network_load'], 'gradient_level': ApproxEqual()},
]) ])
finally: finally:
common.network_load.shutdown() common.network_load.shutdown()