[core] Move "every" to decorators module
This commit is contained in:
parent
11ebcee29a
commit
c625baa47a
3 changed files with 11 additions and 10 deletions
|
@ -1,5 +1,14 @@
|
|||
import util.format
|
||||
|
||||
def every(minutes=0, seconds=0):
|
||||
def decorator_init(init):
|
||||
def call_init(obj, *args, **kwargs):
|
||||
init(obj, *args, **kwargs)
|
||||
if obj.parameter('interval') is None:
|
||||
obj.set('interval', minutes*60 + seconds)
|
||||
return call_init
|
||||
return decorator_init
|
||||
|
||||
def scrollable(func):
|
||||
def wrapper(module, widget):
|
||||
text = func(module, widget)
|
||||
|
|
|
@ -12,15 +12,6 @@ except Exception as e:
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
def every(minutes=0, seconds=0):
|
||||
def decorator_init(init):
|
||||
def call_init(obj, *args, **kwargs):
|
||||
init(obj, *args, **kwargs)
|
||||
if obj.parameter('interval') is None:
|
||||
obj.set('interval', minutes*60 + seconds)
|
||||
return call_init
|
||||
return decorator_init
|
||||
|
||||
def load(module_name, config=None):
|
||||
error = None
|
||||
for namespace in [ 'core', 'contrib' ]:
|
||||
|
|
|
@ -6,9 +6,10 @@ import platform
|
|||
|
||||
import core.module
|
||||
import core.widget
|
||||
import core.decorators
|
||||
|
||||
class Module(core.module.Module):
|
||||
@core.module.every(minutes=60)
|
||||
@core.decorators.every(minutes=60)
|
||||
def __init__(self, config):
|
||||
super().__init__(config, core.widget.Widget(self.full_text))
|
||||
|
||||
|
|
Loading…
Reference in a new issue