From bc90382ecb70ca7eb91c7f8631d00c53178de3b2 Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Thu, 6 Jan 2022 00:10:27 +1000 Subject: [PATCH] Coding style. - Simpler way to do decorators. --- fill3/fill3/__init__.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/fill3/fill3/__init__.py b/fill3/fill3/__init__.py index 40fd07f..41e4de8 100755 --- a/fill3/fill3/__init__.py +++ b/fill3/fill3/__init__.py @@ -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):