From 8538f272d6bfc5614ebb9f71cfbc3ef48b553cf6 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Mon, 31 Oct 2016 07:46:21 +0100 Subject: [PATCH] [rework] Replace old-style string formatting with new-style --- bumblebee/modules/battery.py | 6 +++--- bumblebee/outputs/i3.py | 2 +- bumblebee/theme.py | 2 +- i3bumblebee | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bumblebee/modules/battery.py b/bumblebee/modules/battery.py index 7f5207e..d4367f8 100644 --- a/bumblebee/modules/battery.py +++ b/bumblebee/modules/battery.py @@ -9,13 +9,13 @@ class Module(bumblebee.module.Module): self._status = "Unknown" 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()) - return "%02d%%" % self._capacity + return "{:02d}%".format(self._capacity) 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() if self._status == "Discharging": return "discharging" diff --git a/bumblebee/outputs/i3.py b/bumblebee/outputs/i3.py index c8a7351..aca04cd 100644 --- a/bumblebee/outputs/i3.py +++ b/bumblebee/outputs/i3.py @@ -12,7 +12,7 @@ class i3bar(bumblebee.output.Output): theme = obj.theme() 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: data["separator"] = False diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 5227fe2..bae3299 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -5,7 +5,7 @@ class Theme: def __init__(self, name="default"): self._data = None 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._defaults = self._data.get("defaults", {}) diff --git a/i3bumblebee b/i3bumblebee index e74c12b..9ef8bce 100755 --- a/i3bumblebee +++ b/i3bumblebee @@ -30,7 +30,7 @@ def main(): # (useful error messages) module_name = m if not ":" in m else m.split(":")[0] 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)) output = bumblebee.outputs.i3.i3bar()