[core] Refactor -> replace some getter/setter pairs with attributes
Remove some set_* methods and replace them with a simple attribute. see #23
This commit is contained in:
parent
068968bbf5
commit
e59e969bdc
7 changed files with 16 additions and 21 deletions
|
@ -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()
|
||||
|
|
|
@ -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"""
|
||||
|
|
|
@ -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":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue