[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:
parent
c2adf38b92
commit
7f91b8298f
5 changed files with 46 additions and 31 deletions
|
@ -10,23 +10,23 @@ import bumblebee.output
|
|||
import bumblebee.modules
|
||||
|
||||
class Engine:
|
||||
def __init__(self, args):
|
||||
def __init__(self, config):
|
||||
self._modules = []
|
||||
self._args = args
|
||||
self._theme = bumblebee.theme.Theme(args)
|
||||
self._output = bumblebee.output.output(args)
|
||||
self._config = config
|
||||
self._theme = bumblebee.theme.Theme(config)
|
||||
self._output = bumblebee.output.output(config)
|
||||
|
||||
def load_module(self, modulespec):
|
||||
name = modulespec.split(self._args.split)[0]
|
||||
args = None if name == modulespec else modulespec.split(self._args.split)[1:]
|
||||
def load_module(self, name):
|
||||
module = importlib.import_module("bumblebee.modules.{}".format(name))
|
||||
return getattr(module, "Module")(self._output, args)
|
||||
return getattr(module, "Module")(self._output, self._config)
|
||||
|
||||
def load_modules(self):
|
||||
for m in self._args.modules:
|
||||
for m in self._config.modules():
|
||||
self._modules.append(self.load_module(m))
|
||||
|
||||
def register_event(self, eventspec):
|
||||
return
|
||||
# TODO
|
||||
event = eventspec.split(self._args.split)
|
||||
if len(event) < 3:
|
||||
raise Exception("invalid click event format, expected 3 parameters")
|
||||
|
@ -37,6 +37,8 @@ class Engine:
|
|||
)
|
||||
|
||||
def register_events(self):
|
||||
return
|
||||
# TODO
|
||||
for e in self._args.events:
|
||||
self.register_event(e)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue