Coding style.
- Simpler way to do decorators.
This commit is contained in:
parent
81588e15d1
commit
bc90382ecb
1 changed files with 12 additions and 14 deletions
|
|
@ -413,20 +413,18 @@ EXCEPTION = None
|
|||
_LAST_APPEARANCE = []
|
||||
|
||||
|
||||
def handle_exception():
|
||||
def decorating_func(func):
|
||||
def wrapper(*args):
|
||||
try:
|
||||
return func(*args)
|
||||
except Exception as exc:
|
||||
global EXCEPTION
|
||||
EXCEPTION = exc
|
||||
SHUTDOWN_EVENT.set()
|
||||
return wrapper
|
||||
return decorating_func
|
||||
def handle_exception(func):
|
||||
def wrapper(*args):
|
||||
try:
|
||||
return func(*args)
|
||||
except Exception as exc:
|
||||
global EXCEPTION
|
||||
EXCEPTION = exc
|
||||
SHUTDOWN_EVENT.set()
|
||||
return wrapper
|
||||
|
||||
|
||||
@handle_exception()
|
||||
@handle_exception
|
||||
def draw_screen(widget):
|
||||
global _LAST_APPEARANCE
|
||||
appearance = widget.appearance(os.get_terminal_size())
|
||||
|
|
@ -434,7 +432,7 @@ def draw_screen(widget):
|
|||
_LAST_APPEARANCE = appearance
|
||||
|
||||
|
||||
@handle_exception()
|
||||
@handle_exception
|
||||
def patch_screen(widget):
|
||||
global _LAST_APPEARANCE
|
||||
appearance = widget.appearance(os.get_terminal_size())
|
||||
|
|
@ -453,7 +451,7 @@ async def update_screen(screen_widget):
|
|||
APPEARANCE_CHANGED_EVENT.clear()
|
||||
|
||||
|
||||
@handle_exception()
|
||||
@handle_exception
|
||||
def on_terminal_input(screen_widget):
|
||||
term_code = sys.stdin.read()
|
||||
if term_code.startswith(terminal.MOUSE):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue