From 31067159d604f40fcaa0ca08468056f263bee7f9 Mon Sep 17 00:00:00 2001 From: Tobi-wan Kenobi Date: Fri, 2 Dec 2016 19:06:47 +0100 Subject: [PATCH] [modules/nic] Minor refactoring Remove impractical cache. --- bumblebee/modules/nic.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bumblebee/modules/nic.py b/bumblebee/modules/nic.py index 64483c5..0db9e3a 100644 --- a/bumblebee/modules/nic.py +++ b/bumblebee/modules/nic.py @@ -13,8 +13,6 @@ class Module(bumblebee.module.Module): def __init__(self, output, config): super(Module, self).__init__(output, config) self._exclude = tuple(filter(len, self._config.parameter("exclude", "lo,virbr,docker,vboxnet,veth").split(","))) - self._state = "down" - self._typecache = {} def widgets(self): result = [] @@ -50,12 +48,10 @@ class Module(bumblebee.module.Module): def state(self, widget): intf = widget.get("intf") - if not intf in self._typecache: - t = "wireless" if self._iswlan(intf) else "wired" - t = "tunnel" if self._istunnel(intf) else t - self._typecache[intf] = t + iftype = "wireless" if self._iswlan(intf) else "wired" + iftype = "tunnel" if self._istunnel(intf) else iftype - return "{}-{}".format(self._typecache[intf], widget.get("state")) + return "{}-{}".format(iftype, widget.get("state")) def warning(self, widget): return widget.get("state") != "up"