diff --git a/core/module.py b/core/module.py index 5432df5..bed9702 100644 --- a/core/module.py +++ b/core/module.py @@ -34,7 +34,9 @@ class Module(core.input.Object): self.__widgets = widgets if isinstance(widgets, list) else [ widgets ] for widget in self.__widgets: widget.module = self - self.__name = None + + self.module_name = self.__module__.split('.')[-1] + self.name = self.module_name self.alias = self.__config.get('__alias__', None) self.next_update = None @@ -46,13 +48,13 @@ class Module(core.input.Object): def parameter(self, key, default=None): value = default - for prefix in [ self.name(), self.module_name(), self.alias ]: + for prefix in [ self.name, self.module_name, self.alias ]: value = self.__config.get('{}.{}'.format(prefix, key), value) # TODO retrieve from config file return value def set(self, key, value): - self.__config.set('{}.{}'.format(self.name(), key), value) + self.__config.set('{}.{}'.format(self.name, key), value) def update(self): pass @@ -66,12 +68,6 @@ class Module(core.input.Object): self.__widgets = [module.widget()] self.update = module.update - def name(self): - return self.__name if self.__name else self.module_name() - - def module_name(self): - return self.__module__.split('.')[-1] - def widgets(self, widgets=None): if widgets: self.__widgets = widgets diff --git a/core/output.py b/core/output.py index 1ba740d..cdfb1c4 100644 --- a/core/output.py +++ b/core/output.py @@ -162,7 +162,7 @@ class i3(object): def blocks(self, module): blocks = [] for widget in module.widgets(): - if widget.module and self.__config.autohide(widget.module.name()): + if widget.module and self.__config.autohide(widget.module.name): if not any(state in widget.state() for state in [ 'warning', 'critical']): continue if module.hidden(): diff --git a/core/theme.py b/core/theme.py index 0ece69e..23b9373 100644 --- a/core/theme.py +++ b/core/theme.py @@ -115,7 +115,7 @@ class Theme(object): value = merge_replace(value, self.__data.get(key, value), key) if widget.module: - value = merge_replace(value, self.get(widget.module.name(), None, {}).get(key, value), key) + value = merge_replace(value, self.get(widget.module.name, None, {}).get(key, value), key) if not key in widget.state(): for state in widget.state(): diff --git a/tests/core/test_module.py b/tests/core/test_module.py index 8f9b96d..b206d38 100644 --- a/tests/core/test_module.py +++ b/tests/core/test_module.py @@ -66,8 +66,8 @@ class module(unittest.TestCase): def test_module_Name(self): module = TestModule() - self.assertEqual('test_module', module.name(), 'module has wrong name') - self.assertEqual('test_module', module.module_name(), 'module has wrong name') + self.assertEqual('test_module', module.name, 'module has wrong name') + self.assertEqual('test_module', module.module_name, 'module has wrong name') def testvalid_parameter(self): cfg = core.config.Config(shlex.split('-p test_module.foo=5'))