[modules] critical/warning threshold refactoring

Quite a lot of modules use the "if higher X -> critical, if higher Y ->
warning" idiom now, so extracted that into a common function for reuse.

see #23
This commit is contained in:
Tobi-wan Kenobi 2016-12-11 08:25:54 +01:00
parent edfccd2d31
commit 23d7d53fca
5 changed files with 14 additions and 22 deletions

View file

@ -72,14 +72,10 @@ class Module(bumblebee.engine.Module):
if line.startswith("tag"):
key, value = line.split(" ", 2)[1:]
self._tags.update({ key: value })
if line.startswith("duration"):
self._tags.update({
"duration": bumblebee.util.durationfmt(int(line.split(" ")[1]))
})
if line.startswith("position"):
self._tags.update({
"position": bumblebee.util.durationfmt(int(line.split(" ")[1]))
})
for key in ["duration", "position"]:
if line.startswith(key):
dur = int(line.split(" ")[1])
self._tags.update({key:bumblebee.util.durationfmt(dur)})
if line.startswith("set repeat "):
self._repeat = False if "false" in line else True
if line.startswith("set shuffle "):