[core] Refactor engine

This is going to be a bit more comprehensive than anticipated. In order
to cleanly refactor the core and the engine, basically start from
scratch with the implementation.

Goals:

* Test coverage
* Maintain backwards compatibility with module interface as much as
  possible (but still make modules easier to code)
* Simplicity

see #23
This commit is contained in:
Tobi-wan Kenobi 2016-12-03 20:38:54 +01:00
parent 20858991b9
commit a8a6c9bba2
72 changed files with 19 additions and 2155 deletions

View file

@ -1,38 +0,0 @@
import importlib
import bumblebee.theme
import bumblebee.output
import bumblebee.config
import bumblebee.modules
class Engine:
def __init__(self, config):
self._modules = []
self._config = config
self._theme = bumblebee.theme.Theme(config)
self._output = bumblebee.output.output(config)
def load_module(self, modulespec):
name = modulespec["name"]
module = importlib.import_module("bumblebee.modules.{}".format(name))
cfg = bumblebee.config.ModuleConfig(self._config, name, modulespec["alias"])
obj = getattr(module, "Module")(self._output, cfg)
obj.register_callbacks()
return obj
def load_modules(self):
for m in self._config.modules():
self._modules.append(self.load_module(m))
def run(self):
self._output.start()
while True:
self._theme.begin()
for m in self._modules:
self._output.draw(m.widgets(), self._theme)
self._output.flush()
self._output.wait()
self._output.stop()
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4