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,
'common_config': self.common_config,
'run_once': self.run_once,
}
}
self.ext_config = config['ext'][self.ext]
if self.ext_config != self.prev_ext_config:

View File

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

View File

@ -83,7 +83,7 @@ class BranchSegment(RepositorySegment):
return [{
'contents': branch,
'highlight_group': ['branch_dirty' if repository_status(**kwargs) else 'branch_clean', 'branch'],
}]
}]
else:
return branch
@ -153,7 +153,7 @@ def cwd(pl, dir_shorten_len=None, dir_limit_depth=None):
ret.append({
'contents': part,
'divider_highlight_group': 'cwd:divider',
})
})
ret[-1]['highlight_group'] = ['cwd:current_folder', 'cwd']
return ret
@ -190,7 +190,7 @@ def fuzzy_time(pl):
45: 'quarter to',
50: 'ten to',
55: 'five to',
}
}
special_case_str = {
(23, 58): 'round about midnight',
(23, 59): 'round about midnight',
@ -198,7 +198,7 @@ def fuzzy_time(pl):
(0, 1): 'round about midnight',
(0, 2): 'round about midnight',
(12, 0): 'noon',
}
}
now = datetime.now()
@ -337,17 +337,17 @@ weather_conditions_icons = {
}
temp_conversions = {
'C': lambda temp: temp,
'F': lambda temp: (temp * 9 / 5) + 32,
'K': lambda temp: temp + 273.15,
}
'C': lambda temp: temp,
'F': lambda temp: (temp * 9 / 5) + 32,
'K': lambda temp: temp + 273.15,
}
# Note: there are also unicode characters for units: ℃, ℉ and
temp_units = {
'C': '°C',
'F': '°F',
'K': 'K',
}
'C': '°C',
'F': '°F',
'K': 'K',
}
class WeatherSegment(ThreadedSegment):
@ -371,11 +371,11 @@ class WeatherSegment(ThreadedSegment):
location_data['region_name'],
location_data['country_name']])
query_data = {
'q':
'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'),
'format': 'json',
}
'q':
'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'),
'format': 'json',
}
self.url = 'http://query.yahooapis.com/v1/public/yql?' + urllib_urlencode(query_data)
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)
groups = ['weather_condition_' + icon_name for icon_name in self.icon_names] + ['weather_conditions', 'weather']
return [
{
{
'contents': icon + ' ',
'highlight_group': groups,
'divider_highlight_group': 'background:divider',
},
{
},
{
'contents': temp_format.format(temp=temp),
'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'],
'draw_divider': False,
'divider_highlight_group': 'background:divider',
'gradient_level': gradient_level,
},
]
},
]
weather = with_docstring(WeatherSegment(),
@ -517,7 +517,7 @@ def system_load(pl, format='{avg:.1f}', threshold_good=1, threshold_bad=2):
'draw_divider': False,
'divider_highlight_group': 'background:divider',
'gradient_level': gradient_level,
})
})
ret[0]['draw_divider'] = True
ret[0]['contents'] += ' '
ret[1]['contents'] += ' '
@ -602,9 +602,9 @@ def user(pl):
return None
euid = _geteuid()
return [{
'contents': username,
'highlight_group': 'user' if euid != 0 else ['superuser', 'user'],
}]
'contents': username,
'highlight_group': 'user' if euid != 0 else ['superuser', 'user'],
}]
if os.path.exists('/proc/uptime'):
@ -724,7 +724,7 @@ class NetworkLoadSegment(KwThreadedSegment):
'contents': format.format(value=humanize_bytes(value, suffix, si_prefix)),
'divider_highlight_group': 'background:divider',
'highlight_group': hl_groups,
})
})
if is_gradient:
max = kwargs[max_key]
if value >= max:
@ -804,13 +804,13 @@ class EmailIMAPSegment(KwThreadedSegment):
return [{
'contents': str(unread_count),
'highlight_group': 'email_alert',
}]
}]
else:
return [{
'contents': str(unread_count),
'highlight_group': ['email_alert_gradient', 'email_alert'],
'gradient_level': unread_count * 100.0 / max_msgs,
}]
}]
email_imap_alert = with_docstring(EmailIMAPSegment(),
@ -841,7 +841,7 @@ class NowPlayingSegment(object):
'play': '',
'pause': '▮▮',
'stop': '',
}
}
def __call__(self, player='mpd', format='{state_symbol} {artist} - {title} ({total})', **kwargs):
player_func = getattr(self, 'player_{0}'.format(player))
@ -853,7 +853,7 @@ class NowPlayingSegment(object):
'title': None,
'elapsed': None,
'total': None,
}
}
func_stats = player_func(**kwargs)
if not func_stats:
return None
@ -921,7 +921,7 @@ class NowPlayingSegment(object):
'title': now_playing.get('title'),
'elapsed': self._convert_seconds(now_playing.get('position', 0)),
'total': self._convert_seconds(now_playing.get('duration', 0)),
}
}
def player_mpd(self, pl, host='localhost', port=6600):
try:
@ -942,7 +942,7 @@ class NowPlayingSegment(object):
'title': now_playing.get('title'),
'elapsed': self._convert_seconds(now_playing.get('elapsed', 0)),
'total': self._convert_seconds(now_playing.get('time', 0)),
}
}
except ImportError:
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:
@ -953,7 +953,7 @@ class NowPlayingSegment(object):
'artist': now_playing[1],
'title': now_playing[2],
'total': now_playing[3],
}
}
def player_spotify(self, pl):
try:
@ -981,7 +981,7 @@ class NowPlayingSegment(object):
'artist': info.get('xesam:artist')[0],
'title': info.get('xesam:title'),
'total': self._convert_seconds(info.get('mpris:length') / 1e6),
}
}
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'])
@ -994,5 +994,5 @@ class NowPlayingSegment(object):
'title': now_playing[2],
'elapsed': now_playing[3],
'total': now_playing[4],
}
}
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 [{
'contents': no_file_text,
'highlight_group': ['file_name_no_file', 'file_name'],
}]
}]
else:
return None
file_name = vim_funcs['fnamemodify'](name, ':~:.:t')
@ -258,7 +258,7 @@ def line_percent(pl, segment_info, gradient=False):
'contents': str(int(round(percentage))),
'highlight_group': ['line_percent_gradient', 'line_percent'],
'gradient_level': percentage,
}]
}]
@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']
if status_colors else []) + ['branch'],
'divider_highlight_group': 'branch:divider',
}]
}]
def startup(self, status_colors=False, **kwargs):
super(BranchSegment, self).startup(**kwargs)
@ -422,7 +422,7 @@ class FileVCSStatusSegment(KwWindowThreadedSegment):
ret.append({
'contents': status,
'highlight_group': ['file_vcs_status_' + status, 'file_vcs_status'],
})
})
return ret
return None

View File

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

View File

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

View File

@ -143,35 +143,35 @@ class TestCommon(TestCase):
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': ''},
{'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), [
{'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}
])
])
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': ''},
{'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'}), [
{'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}
])
])
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 '},
{'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'), [
{'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}
])
])
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': ''},
{'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'), [
{'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}
])
])
def test_system_load(self):
pl = Pl()
@ -227,23 +227,23 @@ class TestCommon(TestCase):
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': '⬆ 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}'), [
{'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']},
])
])
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': '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'), [
{'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']},
])
])
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': 's 2 KiB/s', 'highlight_group': ['network_load_sent', 'network_load']},
])
])
class ApproxEqual(object):
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'), [
{'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()},
])
])
finally:
common.network_load.shutdown()