diff --git a/bumblebee/engine.py b/bumblebee/engine.py index ca4bb55..463d244 100644 --- a/bumblebee/engine.py +++ b/bumblebee/engine.py @@ -63,10 +63,10 @@ class Engine(object): def load_modules(self, modules): """Load specified modules and return them as list""" for module in modules: - self._modules.append(self.load_module(module["module"], module["name"])) + self._modules.append(self._load_module(module["module"], module["name"])) return self._modules - def load_module(self, module_name, config_name=None): + def _load_module(self, module_name, config_name=None): """Load specified module and return it as object""" if config_name is None: config_name = module_name @@ -95,7 +95,7 @@ class Engine(object): for module in self._modules: module.update(module.widgets()) for widget in module.widgets(): - widget.set_module(module) + widget.link_module(module) self._output.draw(widget=widget, engine=self) self._output.flush() self._output.end() diff --git a/bumblebee/output.py b/bumblebee/output.py index 5eba197..5d9e0df 100644 --- a/bumblebee/output.py +++ b/bumblebee/output.py @@ -9,18 +9,14 @@ class Widget(object): """Represents a single visible block in the status bar""" def __init__(self, full_text): self._full_text = full_text - self._module = None + self.module = None - def set_module(self, module): + def link_module(self, module): """Set the module that spawned this widget This is done outside the constructor to avoid having to pass in the module name in every concrete module implementation""" - self._module = module.name - - def module(self): - """Return the name of the module that spawned this widget""" - return self._module + self.module = module.name def full_text(self): """Retrieve the full text to display in the widget""" diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 28fe5b3..a8fa6c5 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -63,7 +63,7 @@ class Theme(object): def _get(self, widget, name, default=None): """Return the config value 'name' for 'widget'""" - module_theme = self._theme.get(widget.module(), {}) + module_theme = self._theme.get(widget.module, {}) padding = None if name != "padding": diff --git a/tests/modules/test_modules.py b/tests/modules/test_modules.py index baa6233..60c01e2 100644 --- a/tests/modules/test_modules.py +++ b/tests/modules/test_modules.py @@ -20,6 +20,8 @@ class TestGenericModules(unittest.TestCase): for mod in self.objects: widgets = self.objects[mod].widgets() for widget in widgets: + widget.link_module(self.objects[mod]) + self.assertEquals(widget.module, mod) assertWidgetAttributes(self, widget) def test_update(self): diff --git a/tests/test_engine.py b/tests/test_engine.py index 3aa2f6b..29729f6 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py @@ -26,16 +26,16 @@ class TestEngine(unittest.TestCase): self.assertFalse(self.engine.running()) def test_load_module(self): - module = self.engine.load_module(self.testModule) + module = self.engine._load_module(self.testModule) self.assertEquals(module.__module__, self.testModuleSpec) def test_load_invalid_module(self): with self.assertRaises(ModuleLoadError): - self.engine.load_module(self.invalidModule) + self.engine._load_module(self.invalidModule) def test_load_none(self): with self.assertRaises(ModuleLoadError): - self.engine.load_module(None) + self.engine._load_module(None) def test_load_modules(self): modules = self.engine.load_modules(self.testModules) diff --git a/tests/test_theme.py b/tests/test_theme.py index 3b5690a..4ae9b50 100644 --- a/tests/test_theme.py +++ b/tests/test_theme.py @@ -44,17 +44,17 @@ class TestTheme(unittest.TestCase): self.assertEquals(self.theme.suffix(self.someWidget), self.defaultSuffix) def test_widget_prefix(self): - self.someWidget.attr_module = self.widgetTheme + self.someWidget.module = self.widgetTheme self.assertEquals(self.theme.prefix(self.someWidget), self.widgetPrefix) def test_widget_fg(self): self.assertEquals(self.theme.fg(self.someWidget), self.defaultColor) - self.someWidget.attr_module = self.widgetTheme + self.someWidget.module = self.widgetTheme self.assertEquals(self.theme.fg(self.someWidget), self.widgetColor) def test_widget_bg(self): self.assertEquals(self.theme.bg(self.someWidget), self.defaultBgColor) - self.someWidget.attr_module = self.widgetTheme + self.someWidget.module = self.widgetTheme self.assertEquals(self.theme.bg(self.someWidget), self.widgetBgColor) # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/tests/util.py b/tests/util.py index 7eb73ce..33a65d8 100644 --- a/tests/util.py +++ b/tests/util.py @@ -31,14 +31,11 @@ class MockOutput(object): class MockWidget(object): def __init__(self, text): self._text = text - self.attr_module = None + self.module = None def update(self, widgets): pass - def module(self): - return self.attr_module - def full_text(self): return self._text