[rework] Replace old-style string formatting with new-style

This commit is contained in:
Tobias Witek 2016-10-31 07:46:21 +01:00
parent 60f63f3269
commit 8538f272d6
4 changed files with 6 additions and 6 deletions

View file

@ -9,13 +9,13 @@ class Module(bumblebee.module.Module):
self._status = "Unknown" self._status = "Unknown"
def data(self): def data(self):
with open("/sys/class/power_supply/%s/capacity" % self._battery) as f: with open("/sys/class/power_supply/{}/capacity".format(self._battery)) as f:
self._capacity = int(f.read()) self._capacity = int(f.read())
return "%02d%%" % self._capacity return "{:02d}%".format(self._capacity)
def state(self): def state(self):
with open("/sys/class/power_supply/%s/status" % self._battery) as f: with open("/sys/class/power_supply/{}/status".format(self._battery)) as f:
self._status = f.read().strip() self._status = f.read().strip()
if self._status == "Discharging": if self._status == "Discharging":
return "discharging" return "discharging"

View file

@ -12,7 +12,7 @@ class i3bar(bumblebee.output.Output):
theme = obj.theme() theme = obj.theme()
data = { data = {
"full_text": "%s%s%s" % (theme.prefix(obj), obj.data(), theme.suffix(obj)) "full_text": "{}{}{}".format(theme.prefix(obj), obj.data(), theme.suffix(obj))
} }
if theme.default_separators(obj) == False: if theme.default_separators(obj) == False:
data["separator"] = False data["separator"] = False

View file

@ -5,7 +5,7 @@ class Theme:
def __init__(self, name="default"): def __init__(self, name="default"):
self._data = None self._data = None
path = os.path.dirname(os.path.realpath(__file__)) path = os.path.dirname(os.path.realpath(__file__))
with open("%s/themes/%s.json" % (path, name)) as f: with open("{}/themes/{}.json".format(path, name)) as f:
self._data = json.load(f) self._data = json.load(f)
self._defaults = self._data.get("defaults", {}) self._defaults = self._data.get("defaults", {})

View file

@ -30,7 +30,7 @@ def main():
# (useful error messages) # (useful error messages)
module_name = m if not ":" in m else m.split(":")[0] module_name = m if not ":" in m else m.split(":")[0]
module_args = None if not ":" in m else m.split(":")[1:] module_args = None if not ":" in m else m.split(":")[1:]
module = importlib.import_module("bumblebee.modules.%s" % module_name) module = importlib.import_module("bumblebee.modules.{}".format(module_name))
modules.append(getattr(module, "Module")(theme, module_args)) modules.append(getattr(module, "Module")(theme, module_args))
output = bumblebee.outputs.i3.i3bar() output = bumblebee.outputs.i3.i3bar()