diff --git a/bumblebee/engine.py b/bumblebee/engine.py index ee94186..98964e0 100644 --- a/bumblebee/engine.py +++ b/bumblebee/engine.py @@ -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): diff --git a/bumblebee/input.py b/bumblebee/input.py index ebe11b2..cb8c28a 100644 --- a/bumblebee/input.py +++ b/bumblebee/input.py @@ -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 diff --git a/bumblebee/modules/amixer.py b/bumblebee/modules/amixer.py index 2ac6c89..55d6878 100644 --- a/bumblebee/modules/amixer.py +++ b/bumblebee/modules/amixer.py @@ -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"] diff --git a/bumblebee/modules/battery.py b/bumblebee/modules/battery.py index 61741ed..7638d3f 100644 --- a/bumblebee/modules/battery.py +++ b/bumblebee/modules/battery.py @@ -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") diff --git a/bumblebee/modules/brightness.py b/bumblebee/modules/brightness.py index e61be7e..29ba4e3 100644 --- a/bumblebee/modules/brightness.py +++ b/bumblebee/modules/brightness.py @@ -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" diff --git a/bumblebee/modules/cmus.py b/bumblebee/modules/cmus.py index 2db4c0c..de638e4 100644 --- a/bumblebee/modules/cmus.py +++ b/bumblebee/modules/cmus.py @@ -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 diff --git a/bumblebee/modules/datetime.py b/bumblebee/modules/datetime.py index b116ee9..fe380b4 100644 --- a/bumblebee/modules/datetime.py +++ b/bumblebee/modules/datetime.py @@ -16,7 +16,7 @@ import datetime import locale import bumblebee.engine -ALIASES = [ "date", "time" ] +ALIASES = ["date", "time"] def default_format(module): default = "%x %X" diff --git a/bumblebee/modules/disk.py b/bumblebee/modules/disk.py index a9b7888..db4d522 100644 --- a/bumblebee/modules/disk.py +++ b/bumblebee/modules/disk.py @@ -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)) diff --git a/bumblebee/modules/getcrypto.py b/bumblebee/modules/getcrypto.py index 0884463..502e100 100644 --- a/bumblebee/modules/getcrypto.py +++ b/bumblebee/modules/getcrypto.py @@ -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 diff --git a/bumblebee/modules/mocp.py b/bumblebee/modules/mocp.py index 5c203b2..7ffe263 100644 --- a/bumblebee/modules/mocp.py +++ b/bumblebee/modules/mocp.py @@ -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:"): diff --git a/bumblebee/modules/mpd.py b/bumblebee/modules/mpd.py index af90581..9a9f253 100644 --- a/bumblebee/modules/mpd.py +++ b/bumblebee/modules/mpd.py @@ -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 diff --git a/bumblebee/modules/nic.py b/bumblebee/modules/nic.py index 01a251f..28ffc69 100644 --- a/bumblebee/modules/nic.py +++ b/bumblebee/modules/nic.py @@ -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) diff --git a/bumblebee/modules/nvidiagpu.py b/bumblebee/modules/nvidiagpu.py index 42f1972..8acf68c 100644 --- a/bumblebee/modules/nvidiagpu.py +++ b/bumblebee/modules/nvidiagpu.py @@ -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) diff --git a/bumblebee/modules/pacman.py b/bumblebee/modules/pacman.py index 81941e1..44f0c9c 100644 --- a/bumblebee/modules/pacman.py +++ b/bumblebee/modules/pacman.py @@ -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" diff --git a/bumblebee/modules/ping.py b/bumblebee/modules/ping.py index e19d603..0a1419b 100644 --- a/bumblebee/modules/ping.py +++ b/bumblebee/modules/ping.py @@ -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")) diff --git a/bumblebee/modules/pulseaudio.py b/bumblebee/modules/pulseaudio.py index 5e60d55..d74f4f6 100644 --- a/bumblebee/modules/pulseaudio.py +++ b/bumblebee/modules/pulseaudio.py @@ -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 diff --git a/bumblebee/modules/sensors.py b/bumblebee/modules/sensors.py index 2772dff..ed518f5 100644 --- a/bumblebee/modules/sensors.py +++ b/bumblebee/modules/sensors.py @@ -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) diff --git a/bumblebee/modules/spotify.py b/bumblebee/modules/spotify.py index 9ed47aa..0c62543 100644 --- a/bumblebee/modules/spotify.py +++ b/bumblebee/modules/spotify.py @@ -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") diff --git a/bumblebee/modules/test.py b/bumblebee/modules/test.py index e4099c6..b654575 100644 --- a/bumblebee/modules/test.py +++ b/bumblebee/modules/test.py @@ -5,7 +5,7 @@ import bumblebee.engine -ALIASES = [ "test-alias" ] +ALIASES = ["test-alias"] class Module(bumblebee.engine.Module): def __init__(self, engine, config): diff --git a/bumblebee/modules/todo.py b/bumblebee/modules/todo.py index d96388f..1151c77 100644 --- a/bumblebee/modules/todo.py +++ b/bumblebee/modules/todo.py @@ -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" diff --git a/bumblebee/modules/traffic.py b/bumblebee/modules/traffic.py index 60d5dd7..5b49a21 100644 --- a/bumblebee/modules/traffic.py +++ b/bumblebee/modules/traffic.py @@ -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[:] diff --git a/bumblebee/modules/weather.py b/bumblebee/modules/weather.py index 66334dd..1bad080 100644 --- a/bumblebee/modules/weather.py +++ b/bumblebee/modules/weather.py @@ -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 [] diff --git a/bumblebee/util.py b/bumblebee/util.py index 11119f8..c81d64b 100644 --- a/bumblebee/util.py +++ b/bumblebee/util.py @@ -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