Some fixes for flake8
This commit is contained in:
parent
14d957bdf9
commit
1351207462
|
@ -1,13 +1,13 @@
|
|||
from sphinx.ext import autodoc
|
||||
from sphinx.util.inspect import getargspec
|
||||
from inspect import ArgSpec, getargspec, formatargspec
|
||||
from inspect import ArgSpec, formatargspec
|
||||
from powerline.lib.threaded import ThreadedSegment, KwThreadedSegment
|
||||
from itertools import count
|
||||
|
||||
try:
|
||||
from __builtin__ import unicode
|
||||
except ImportError:
|
||||
unicode = lambda s, enc: s
|
||||
unicode = lambda s, enc: s # NOQA
|
||||
|
||||
|
||||
def formatvalue(val):
|
||||
|
|
|
@ -38,7 +38,7 @@ class PowerlineState(object):
|
|||
def _log(self, attr, msg, *args, **kwargs):
|
||||
prefix = kwargs.get('prefix') or self.prefix
|
||||
msg = ((prefix + ':') if prefix else '') + msg.format(*args, **kwargs)
|
||||
key = attr+':'+prefix
|
||||
key = attr + ':' + prefix
|
||||
if msg != self.last_msgs.get(key):
|
||||
getattr(self.logger, attr)(msg)
|
||||
self.last_msgs[key] = msg
|
||||
|
@ -144,6 +144,7 @@ class Powerline(object):
|
|||
level = getattr(logging, common_config.get('log_level', 'WARNING'))
|
||||
handler = self.get_log_handler(common_config)
|
||||
handler.setLevel(level)
|
||||
handler.setFormatter(formatter)
|
||||
|
||||
logger = logging.getLogger('powerline')
|
||||
logger.setLevel(level)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# vim:fileencoding=utf-8:noet
|
||||
from powerline.ipython import IpythonPowerline
|
||||
from IPython.Prompts import BasePrompt, Prompt1
|
||||
from IPython.Prompts import BasePrompt
|
||||
from IPython.ipapi import get as get_ipython
|
||||
from IPython.ipapi import TryNext
|
||||
|
||||
|
@ -88,6 +88,7 @@ class PowerlinePrompt1(PowerlinePrompt):
|
|||
return RewriteResult(self.powerline.renderer.render(matcher_info='rewrite', width=self.prompt_text_len, segment_info=self.powerline_segment_info)
|
||||
+ (' ' * self.nrspaces))
|
||||
|
||||
|
||||
class PowerlinePromptOut(PowerlinePrompt):
|
||||
powerline_prompt_type = 'out'
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ if sys.version_info < (3,) or not hasattr(vim, 'bindeval'):
|
|||
getbufvar = vim_get_func('getbufvar')
|
||||
else:
|
||||
_getbufvar = vim_get_func('getbufvar')
|
||||
|
||||
def getbufvar(*args):
|
||||
r = _getbufvar(*args)
|
||||
if type(r) is bytes:
|
||||
|
|
|
@ -27,7 +27,7 @@ class ScannerError(MarkedError):
|
|||
try:
|
||||
from __builtin__ import unicode
|
||||
except ImportError:
|
||||
unicode = str
|
||||
unicode = str # NOQA
|
||||
|
||||
|
||||
class SimpleKey:
|
||||
|
|
|
@ -61,7 +61,7 @@ class VimRenderer(Renderer):
|
|||
# renderer
|
||||
return vim.strwidth(string.encode('utf-8'))
|
||||
else:
|
||||
@staticmethod
|
||||
@staticmethod # NOQA
|
||||
def strwidth(string):
|
||||
return vim.strwidth(string)
|
||||
|
||||
|
|
|
@ -389,7 +389,7 @@ class WeatherSegment(ThreadedSegment):
|
|||
|
||||
try:
|
||||
icon_names = weather_conditions_codes[condition_code]
|
||||
except IndexError as e:
|
||||
except IndexError:
|
||||
if condition_code == 3200:
|
||||
icon_names = ('not_available',)
|
||||
self.warn('Weather is not available for location {0}', self.location)
|
||||
|
@ -561,7 +561,7 @@ except ImportError:
|
|||
tx = int(file_obj.read())
|
||||
return (rx, tx)
|
||||
|
||||
def _get_interfaces():
|
||||
def _get_interfaces(): # NOQA
|
||||
for interface in os.listdir('/sys/class/net'):
|
||||
x = _get_bytes(interface)
|
||||
if x is not None:
|
||||
|
@ -613,6 +613,7 @@ if os.path.exists('/proc/uptime'):
|
|||
return int(float(f.readline().split()[0]))
|
||||
elif 'psutil' in globals():
|
||||
from time import time
|
||||
|
||||
def _get_uptime(): # NOQA
|
||||
# psutil.BOOT_TIME is not subject to clock adjustments, but time() is.
|
||||
# Thus it is a fallback to /proc/uptime reading and not the reverse.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
from powerline.theme import requires_segment_info
|
||||
|
||||
|
||||
@requires_segment_info
|
||||
def prompt_count(pl, segment_info):
|
||||
return str(segment_info.prompt_count)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# vim:fileencoding=utf-8:noet
|
||||
import imp
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
class Pl(object):
|
||||
|
|
|
@ -196,6 +196,7 @@ class TestCommon(TestCase):
|
|||
return None
|
||||
|
||||
f = [gb]
|
||||
|
||||
def _get_bytes(interface):
|
||||
return f[0](interface)
|
||||
|
||||
|
@ -237,9 +238,11 @@ class TestCommon(TestCase):
|
|||
{'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):
|
||||
return abs(i - 50.0) < 1
|
||||
|
||||
self.assertEqual(common.network_load(pl=pl, recv_format='r {value}', sent_format='s {value}', sent_max=4800), [
|
||||
{'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()},
|
||||
|
|
|
@ -45,6 +45,7 @@ def _construct_result(r):
|
|||
|
||||
def _str_func(func):
|
||||
from functools import wraps
|
||||
|
||||
@wraps(func)
|
||||
def f(*args, **kwargs):
|
||||
return _construct_result(func(*args, **kwargs))
|
||||
|
|
|
@ -7,7 +7,7 @@ from itertools import groupby
|
|||
try:
|
||||
from __builtin__ import unicode
|
||||
except ImportError:
|
||||
unicode = str
|
||||
unicode = str # NOQA
|
||||
|
||||
|
||||
if len(sys.argv) == 1 or sys.argv[1] == '--help':
|
||||
|
|
Loading…
Reference in New Issue