poezio/src/decorators.py
mathieui 186803d9a9 Fix formatting, some typos, and unused code, and add docstrings
- No idea why subclasses of ConversationTab were working before
    (info_header was overriden with None in __init__)
- Or why the date parsing worked (“Exeception”)
- Some more reformatting with pylint indications
- Document each module in the tabs module
2014-03-23 00:15:01 +01:00

43 lines
1.1 KiB
Python

"""
Module containing various decorators
"""
class RefreshWrapper(object):
def __init__(self):
self.core = None
def conditional(self, func):
"""
Decorator to refresh the UI if the wrapped function
returns True
"""
def wrap(*args, **kwargs):
ret = func(*args, **kwargs)
if self.core and ret:
self.core.refresh_window()
return ret
return wrap
def always(self, func):
"""
Decorator that refreshs the UI no matter what after the function
"""
def wrap(*args, **kwargs):
ret = func(*args, **kwargs)
if self.core:
self.core.refresh_window()
return ret
return wrap
def update(self, func):
"""
Decorator that only updates the screen
"""
def wrap(*args, **kwargs):
ret = func(*args, **kwargs)
if self.core:
self.core.doupdate()
return ret
return wrap
refresh_wrapper = RefreshWrapper()