[core/engine] Add aliasing mechanism to modules
Allow modules to define aliases. This replaces the symlink mechanism that was in place previously, because it was a bit ugly (and confused code climate). see #23
This commit is contained in:
parent
8f759e6134
commit
2cc2cf8282
5 changed files with 18 additions and 13 deletions
|
@ -12,6 +12,8 @@ from __future__ import absolute_import
|
|||
import datetime
|
||||
import bumblebee.engine
|
||||
|
||||
ALIASES = [ "date", "time" ]
|
||||
|
||||
def default_format(module):
|
||||
default = "%x %X"
|
||||
if module == "date":
|
||||
|
@ -25,8 +27,7 @@ class Module(bumblebee.engine.Module):
|
|||
super(Module, self).__init__(engine, config,
|
||||
bumblebee.output.Widget(full_text=self.get_time)
|
||||
)
|
||||
module = self.__module__.split(".")[-1]
|
||||
self._fmt = self.parameter("format", default_format(module))
|
||||
self._fmt = self.parameter("format", default_format(self.name))
|
||||
|
||||
def get_time(self):
|
||||
return datetime.datetime.now().strftime(self._fmt)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue