[modules/nic] Minor refactoring

Remove impractical cache.
This commit is contained in:
Tobi-wan Kenobi 2016-12-02 19:06:47 +01:00
parent 2f3f171ca5
commit 31067159d6

View file

@ -13,8 +13,6 @@ class Module(bumblebee.module.Module):
def __init__(self, output, config): def __init__(self, output, config):
super(Module, self).__init__(output, config) super(Module, self).__init__(output, config)
self._exclude = tuple(filter(len, self._config.parameter("exclude", "lo,virbr,docker,vboxnet,veth").split(","))) self._exclude = tuple(filter(len, self._config.parameter("exclude", "lo,virbr,docker,vboxnet,veth").split(",")))
self._state = "down"
self._typecache = {}
def widgets(self): def widgets(self):
result = [] result = []
@ -50,12 +48,10 @@ class Module(bumblebee.module.Module):
def state(self, widget): def state(self, widget):
intf = widget.get("intf") intf = widget.get("intf")
if not intf in self._typecache: iftype = "wireless" if self._iswlan(intf) else "wired"
t = "wireless" if self._iswlan(intf) else "wired" iftype = "tunnel" if self._istunnel(intf) else iftype
t = "tunnel" if self._istunnel(intf) else t
self._typecache[intf] = t
return "{}-{}".format(self._typecache[intf], widget.get("state")) return "{}-{}".format(iftype, widget.get("state"))
def warning(self, widget): def warning(self, widget):
return widget.get("state") != "up" return widget.get("state") != "up"