From d9943e3222f78a1d725bf5d00a1f51ce0eb18ca3 Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 22 Feb 2013 18:38:44 +0400 Subject: [PATCH] Fix various flake8 errors --- powerline/bindings/zsh/__init__.py | 1 + powerline/lib/__init__.py | 1 + powerline/segment.py | 7 ++++--- powerline/shell.py | 1 - powerline/vim.py | 4 +++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/powerline/bindings/zsh/__init__.py b/powerline/bindings/zsh/__init__.py index b0e3ffe4..13795fbe 100644 --- a/powerline/bindings/zsh/__init__.py +++ b/powerline/bindings/zsh/__init__.py @@ -1,4 +1,5 @@ import zsh +import json from powerline.shell import ShellPowerline diff --git a/powerline/lib/__init__.py b/powerline/lib/__init__.py index ed4eaafb..fbdacfca 100644 --- a/powerline/lib/__init__.py +++ b/powerline/lib/__init__.py @@ -7,6 +7,7 @@ def underscore_to_camelcase(string): '''Return a underscore_separated_string as CamelCase.''' return ''.join(word.capitalize() or '_' for word in string.split('_')) + def mergedicts(d1, d2): '''Recursively merge two dictionaries. First dictionary is modified in-place. ''' diff --git a/powerline/segment.py b/powerline/segment.py index d8fd8170..0175ff04 100644 --- a/powerline/segment.py +++ b/powerline/segment.py @@ -12,7 +12,7 @@ def get_segment_key(segment, theme_configs, key, module=None, default=None): name = segment['name'] for theme_config in theme_configs: if 'segment_data' in theme_config: - for segment_key in ((module+'.'+name, name) if module else (name,)): + for segment_key in ((module + '.' + name, name) if module else (name,)): try: return theme_config['segment_data'][segment_key][key] except KeyError: @@ -47,9 +47,10 @@ segment_getters = { def gen_segment_getter(ext, path, theme_configs, default_module=None): data = { - 'default_module': default_module or 'powerline.segments.'+ext, + 'default_module': default_module or 'powerline.segments.' + ext, 'path': path, } + def get_key(segment, module, key, default=None): return get_segment_key(segment, theme_configs, key, module, default) data['get_key'] = get_key @@ -68,7 +69,7 @@ def gen_segment_getter(ext, path, theme_configs, default_module=None): 'highlight_group': highlight_group, 'divider_highlight_group': divider_highlight_group, 'before': get_key(segment, module, 'before', ''), - 'after': get_key(segment, module, 'after', ''), + 'after': get_key(segment, module, 'after', ''), 'contents_func': contents_func, 'contents': contents, 'args': get_key(segment, module, 'args', {}) if segment_type == 'function' else {}, diff --git a/powerline/shell.py b/powerline/shell.py index 7e11ac99..d394b7ec 100644 --- a/powerline/shell.py +++ b/powerline/shell.py @@ -7,7 +7,6 @@ from powerline.lib import mergedicts def mergeargs(argvalue): if not argvalue: return None - l = argvalue r = dict([argvalue[0]]) for subval in argvalue[1:]: mergedicts(r, dict([subval])) diff --git a/powerline/vim.py b/powerline/vim.py index 89d3254a..968aa510 100644 --- a/powerline/vim.py +++ b/powerline/vim.py @@ -11,6 +11,7 @@ import vim vim_exists = vim_get_func('exists', rettype=int) + def _override_from(config, override_varname): if vim_exists(override_varname): # FIXME vim.eval has problem with numeric types, vim.bindeval may be @@ -51,7 +52,8 @@ class VimPowerline(Powerline): # Note: themes with non-[a-zA-Z0-9_] names are impossible to override # (though as far as I know exists() won’t throw). Won’t fix, use proper # theme names. - return _override_from(super(VimPowerline, self).load_theme_config(name), 'g:powerline_theme_overrides__'+name) + return _override_from(super(VimPowerline, self).load_theme_config(name), + 'g:powerline_theme_overrides__' + name) def get_local_themes(self, local_themes): self.get_matcher = gen_matcher_getter(self.ext, self.import_paths)