Fix bad-whitespace errors found by pylint

This commit is contained in:
Frederic Junod 2017-10-13 17:06:18 +02:00
parent 7af57c7fc4
commit 57204a215e
23 changed files with 66 additions and 66 deletions

View file

@ -39,7 +39,7 @@ class Module(object):
self.id = self.name
self._configFile = None
for cfg in [ os.path.expanduser("~/.bumblebee-status.conf"), os.path.expanduser("~/.config/bumblebee-status.conf") ]:
for cfg in [os.path.expanduser("~/.bumblebee-status.conf"), os.path.expanduser("~/.config/bumblebee-status.conf")]:
if os.path.exists(cfg):
self._configFile = RawConfigParser()
self._configFile.read(cfg)
@ -138,11 +138,11 @@ class Engine(object):
def _register_module_callbacks(self, module):
buttons = [
{ "name": "left-click", "id": bumblebee.input.LEFT_MOUSE },
{ "name": "middle-click", "id": bumblebee.input.MIDDLE_MOUSE },
{ "name": "right-click", "id": bumblebee.input.RIGHT_MOUSE },
{ "name": "wheel-up", "id": bumblebee.input.WHEEL_UP },
{ "name": "wheel-down", "id": bumblebee.input.WHEEL_DOWN },
{"name": "left-click", "id": bumblebee.input.LEFT_MOUSE},
{"name": "middle-click", "id": bumblebee.input.MIDDLE_MOUSE},
{"name": "right-click", "id": bumblebee.input.RIGHT_MOUSE},
{"name": "wheel-up", "id": bumblebee.input.WHEEL_UP},
{"name": "wheel-down", "id": bumblebee.input.WHEEL_DOWN},
]
for button in buttons:
if module.parameter(button["name"], None):

View file

@ -137,6 +137,6 @@ class I3BarInput(object):
except Exception:
# fall back to global default
if not "__fallback" in event:
return self.callback({ "name": None, "instance": None, "__fallback": True, "button": event["button"] })
return self.callback({"name": None, "instance": None, "__fallback": True, "button": event["button"]})
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

View file

@ -38,5 +38,5 @@ class Module(bumblebee.engine.Module):
def state(self, widget):
if self._muted:
return [ "warning", "muted" ]
return [ "unmuted" ]
return ["warning", "muted"]
return ["unmuted"]

View file

@ -30,9 +30,9 @@ class Module(bumblebee.engine.Module):
if self._batteries[0] == "auto":
self._batteries = glob.glob("/sys/class/power_supply/BAT*")
else:
self._batteries = [ "/sys/class/power_supply/{}".format(b) for b in self._batteries ]
self._batteries = ["/sys/class/power_supply/{}".format(b) for b in self._batteries]
if len(self._batteries) == 0:
self._batteries = [ "/sys/class/power_supply/BAT0" ]
self._batteries = ["/sys/class/power_supply/BAT0"]
self.update(widgets)
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
cmd="gnome-power-statistics")
@ -108,7 +108,7 @@ class Module(bumblebee.engine.Module):
with open("{}/status".format(widget.name)) as f:
charge = f.read().strip()
if charge == "Discharging":
state.append("discharging-{}".format(min([10, 25, 50, 80, 100] , key=lambda i:abs(i-capacity))))
state.append("discharging-{}".format(min([10, 25, 50, 80, 100], key=lambda i: abs(i-capacity))))
else:
if capacity > 95:
state.append("charged")

View file

@ -39,7 +39,7 @@ class Module(bumblebee.engine.Module):
backlight = int(f.readline())
with open("{}/max_brightness".format(self._device_path)) as f:
max_brightness = int(f.readline())
self._brightness=float(backlight*100/max_brightness)
self._brightness = float(backlight*100/max_brightness)
except:
return "Error"

View file

@ -68,7 +68,7 @@ class Module(bumblebee.engine.Module):
return returns.get(widget.name, self._status)
def _eval_line(self, line):
name, key, value = (line.split(" ", 2) + [None, None])[:3]
name, key, value = (line.split(" ", 2) + [None, None])[:3]
if name == "status":
self._status = key

View file

@ -16,7 +16,7 @@ import datetime
import locale
import bumblebee.engine
ALIASES = [ "date", "time" ]
ALIASES = ["date", "time"]
def default_format(module):
default = "%x %X"

View file

@ -50,11 +50,11 @@ class Module(bumblebee.engine.Module):
spercent = self.has_parameter("showPercent")
if all(not param for param in (sused, ssize, spercent)):
return self._format.format(path = self._path,
used = used_str,
left = left_str,
size = size_str,
percent = percent_str)
return self._format.format(path=self._path,
used=used_str,
left=left_str,
size=size_str,
percent=percent_str)
else:
rv = ""
sused = bumblebee.util.asbool(self.parameter("showUsed", True))

View file

@ -20,7 +20,7 @@ import bumblebee.input
import bumblebee.output
import bumblebee.engine
from requests.exceptions import RequestException
def getfromkrak(coin,currency):
def getfromkrak(coin, currency):
abbrev = {
"Btc": ["xbt", "XXBTZ"],
"Eth": ["eth", "XETHZ"],
@ -63,11 +63,11 @@ class Module(bumblebee.engine.Module):
currency = self._getcur
btcprice, ethprice, ltcprice = "", "", ""
if self._getbtc:
btcprice= getfromkrak('Btc',currency)
btcprice = getfromkrak('Btc', currency)
if self._geteth:
ethprice=getfromkrak('Eth',currency)
ethprice = getfromkrak('Eth', currency)
if self._getltc:
ltcprice=getfromkrak('Ltc',currency)
ltcprice = getfromkrak('Ltc', currency)
self._curprice = btcprice+" "*(self._getbtc*self._geteth)+ethprice+" "*(self._getltc*max(self._getbtc, self._geteth))+ltcprice
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

View file

@ -35,7 +35,7 @@ class Module(bumblebee.engine.Module):
#@scrollable
def description(self, widget):
if self._running == 1:
display = self._status + ": " + self._artist + " - " + self._title + " | " + self._position + "/" + self._duration
display = self._status + ": " + self._artist + " - " + self._title + " | " + self._position + "/" + self._duration
else:
display = "Music On Console Player"
return display
@ -53,7 +53,7 @@ class Module(bumblebee.engine.Module):
self._artist = line.split(": ", 2)[1]
if line.startswith("Title:"):
self._title = line.split(": ", 2)[1]
self._title = self._title.split("(by ",2)[0]
self._title = self._title.split("(by ", 2)[0]
if line.startswith("CurrentTime:"):
self._position = line.split(": ", 2)[1]
if line.startswith("TotalTime:"):

View file

@ -106,6 +106,6 @@ class Module(bumblebee.engine.Module):
self._shuffle = False
if line.startswith("tag"):
key, value = line.split(" ", 2)[1:]
self._tags.update({ key: value })
self._tags.update({key: value})
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

View file

@ -72,7 +72,7 @@ class Module(bumblebee.engine.Module):
return retval
def _update_widgets(self, widgets):
interfaces = [ i for i in netifaces.interfaces() if not i.startswith(self._exclude) ]
interfaces = [i for i in netifaces.interfaces() if not i.startswith(self._exclude)]
for widget in widgets:
widget.set("visited", False)

View file

@ -11,14 +11,14 @@ import bumblebee.output
import bumblebee.engine
class Module(bumblebee.engine.Module):
def __init__(self,engine,config):
super(Module,self).__init__(engine,config,bumblebee.output.Widget(full_text=self.utilization))
def __init__(self, engine, config):
super(Module, self).__init__(engine, config, bumblebee.output.Widget(full_text=self.utilization))
self._utilization = "Not found: 0 0/0"
def utilization(self,widget):
def utilization(self, widget):
return self._utilization
def update(self,widgets):
def update(self, widgets):
sp = subprocess.Popen(['nvidia-smi', '-q'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out_str = sp.communicate()
out_list = out_str[0].decode("utf-8").split('\n')
@ -43,4 +43,4 @@ class Module(bumblebee.engine.Module):
name = val
except:
title = item.strip()
self._utilization = u"%s: %s°C %s/%s"%(name,temp,usedMem,totalMem)
self._utilization = u"%s: %s°C %s/%s"%(name, temp, usedMem, totalMem)

View file

@ -47,12 +47,12 @@ class Module(bumblebee.engine.Module):
self._count = 0
def updates(self, widget):
return '/'.join(map(lambda x: str(widget.get(x,0)), repos))
return '/'.join(map(lambda x: str(widget.get(x, 0)), repos))
def update(self, widgets):
path = os.path.dirname(os.path.abspath(__file__))
if self._count == 0:
thread = threading.Thread(target=get_pacman_info, args=(widgets[0],path))
thread = threading.Thread(target=get_pacman_info, args=(widgets[0], path))
thread.start()
# TODO: improve this waiting mechanism a bit
@ -60,7 +60,7 @@ class Module(bumblebee.engine.Module):
self._count = 0 if self._count > 300 else self._count
def state(self, widget):
weightedCount = sum(map(lambda x: (len(repos)-x[0]) * widget.get(x[1],0), enumerate(repos)))
weightedCount = sum(map(lambda x: (len(repos)-x[0]) * widget.get(x[1], 0), enumerate(repos)))
if weightedCount < 10:
return "good"

View file

@ -30,10 +30,10 @@ def get_rtt(module, widget):
))
for line in res.split("\n"):
if line.startswith( "{} packets transmitted".format( widget.get( "rtt-probes" ) ) ):
m = re.search( r'(\d+)% packet loss', line )
if line.startswith("{} packets transmitted".format(widget.get("rtt-probes"))):
m = re.search(r'(\d+)% packet loss', line)
widget.set( 'packet-loss', m.group(1) )
widget.set('packet-loss', m.group(1))
if not line.startswith("rtt"): continue
m = re.search(r'([0-9\.]+)/([0-9\.]+)/([0-9\.]+)/([0-9\.]+)\s+(\S+)', line)
@ -67,7 +67,7 @@ class Module(bumblebee.engine.Module):
widget.get("address"),
widget.get("rtt-avg"),
widget.get("rtt-unit"),
widget.get( 'packet-loss' )
widget.get('packet-loss')
)
def state(self, widget):
@ -77,7 +77,7 @@ class Module(bumblebee.engine.Module):
def update(self, widgets):
if int(time.time()) < self._next_check:
return
thread = threading.Thread(target=get_rtt, args=(self,widgets[0],))
thread = threading.Thread(target=get_rtt, args=(self, widgets[0],))
thread.start()
self._next_check = int(time.time()) + int(widgets[0].get("interval"))

View file

@ -18,7 +18,7 @@ import bumblebee.input
import bumblebee.output
import bumblebee.engine
ALIASES = [ "pasink", "pasource" ]
ALIASES = ["pasink", "pasource"]
class Module(bumblebee.engine.Module):
def __init__(self, engine, config):
@ -38,17 +38,17 @@ class Module(bumblebee.engine.Module):
channel = "sink" if self.name == "pasink" else "source"
self._patterns = [
{ "expr": "name:", "callback": (lambda line: False) },
{ "expr": "muted:", "callback": (lambda line: self.mute(False if " no" in line.lower() else True)) },
{ "expr": "volume:", "callback": self.getvolume },
{"expr": "name:", "callback": (lambda line: False)},
{"expr": "muted:", "callback": (lambda line: self.mute(False if " no" in line.lower() else True))},
{"expr": "volume:", "callback": self.getvolume},
]
engine.input.register_callback(self, button=bumblebee.input.RIGHT_MOUSE, cmd="pavucontrol")
events = [
{ "type": "mute", "action": "toggle", "button": bumblebee.input.LEFT_MOUSE },
{ "type": "volume", "action": "+2%", "button": bumblebee.input.WHEEL_UP },
{ "type": "volume", "action": "-2%", "button": bumblebee.input.WHEEL_DOWN },
{"type": "mute", "action": "toggle", "button": bumblebee.input.LEFT_MOUSE},
{"type": "volume", "action": "+2%", "button": bumblebee.input.WHEEL_UP},
{"type": "volume", "action": "-2%", "button": bumblebee.input.WHEEL_DOWN},
]
for event in events:
@ -120,7 +120,7 @@ class Module(bumblebee.engine.Module):
def state(self, widget):
if self._mute:
return [ "warning", "muted" ]
return [ "unmuted" ]
return ["warning", "muted"]
return ["unmuted"]
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

View file

@ -46,14 +46,14 @@ class Module(bumblebee.engine.Module):
log.debug("retrieved temperature from 'sensors -u'")
return temperature
def get_mhz( self ):
def get_mhz(self):
try:
output = open("/sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq").read()
mhz = int(float(output)/1000.0)
except:
output = open("/proc/cpuinfo").read()
m = re.search(r"cpu MHz\s+:\s+(\d+)", output)
mhz = int(m.group(1))
m = re.search(r"cpu MHz\s+:\s+(\d+)", output)
mhz = int(m.group(1))
if mhz < 1000:
return "{} MHz".format(mhz)

View file

@ -28,7 +28,7 @@ class Module(bumblebee.engine.Module):
self._song = ""
self._format = self.parameter("format", "{artist} - {title}")
cmd="dbus-send --session --type=method_call --dest=org.mpris.MediaPlayer2.spotify \
cmd = "dbus-send --session --type=method_call --dest=org.mpris.MediaPlayer2.spotify \
/org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player."
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
cmd=cmd + "Previous")

View file

@ -5,7 +5,7 @@
import bumblebee.engine
ALIASES = [ "test-alias" ]
ALIASES = ["test-alias"]
class Module(bumblebee.engine.Module):
def __init__(self, engine, config):

View file

@ -29,7 +29,7 @@ class Module(bumblebee.engine.Module):
def state(self, widgets):
if self._todos == 0 :
if self._todos == 0:
return "empty"
return "items"

View file

@ -67,7 +67,7 @@ class Module(bumblebee.engine.Module):
return retval
def _update_widgets(self, widgets):
interfaces = [ i for i in netifaces.interfaces() if not i.startswith(self._exclude) ]
interfaces = [i for i in netifaces.interfaces() if not i.startswith(self._exclude)]
del widgets[:]

View file

@ -60,22 +60,22 @@ class Module(bumblebee.engine.Module):
return u"?"
return self.city() + self.temperature()
def state( self, widget ):
def state(self, widget):
if self._valid:
if "thunderstorm" in self._weather:
return [ 'thunder' ]
return ['thunder']
elif "drizzle" in self._weather:
return [ 'rain' ]
return ['rain']
elif "rain" in self._weather:
return [ 'rain' ]
return ['rain']
elif "snow" in self._weather:
return [ 'snow' ]
return ['snow']
elif "sleet" in self._weather:
return [ 'sleet' ]
return ['sleet']
elif "clear" in self._weather:
return [ 'clear' ]
return ['clear']
elif "cloud" in self._weather:
return [ 'clouds' ]
return ['clouds']
else:
return []

View file

@ -40,7 +40,7 @@ def execute(cmd, wait=True):
return rv
def bytefmt(num):
for unit in [ "", "Ki", "Mi", "Gi" ]:
for unit in ["", "Ki", "Mi", "Gi"]:
if num < 1024.0:
return "{:.2f}{}B".format(num, unit)
num /= 1024.0