[modules] Refactor module initialization

Modules now get an output and a complete config object. This should make
customization much easier in the future.
This commit is contained in:
Tobias Witek 2016-11-05 08:11:08 +01:00
parent c2adf38b92
commit 7f91b8298f
5 changed files with 46 additions and 31 deletions

View file

@ -18,8 +18,8 @@ def description():
return "Displays the current time, using the optional format string as input for strftime."
class Module(bumblebee.module.Module):
def __init__(self, output, args):
super(Module, self).__init__(args)
def __init__(self, output, config):
super(Module, self).__init__(output, config)
module = self.__module__.split(".")[-1]
default = "%x %X"
@ -28,8 +28,8 @@ class Module(bumblebee.module.Module):
if module == "time":
default = "%X"
self._fmt = args[0] if args else default
param_name = "{}.format".format(module)
self._fmt = config.parameter(param_name, default)
def data(self):
return datetime.datetime.now().strftime(self._fmt)