From ed7e4136c7e1bbbc9440ddcc5c64c64dd42140e0 Mon Sep 17 00:00:00 2001 From: Silas Kraume Date: Fri, 27 Oct 2023 00:44:14 +0200 Subject: [PATCH] only display curses warning once --- cat_win/util/editor.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cat_win/util/editor.py b/cat_win/util/editor.py index a6f9d709..071a8b52 100644 --- a/cat_win/util/editor.py +++ b/cat_win/util/editor.py @@ -35,6 +35,8 @@ class Editor: """ Editor """ + loading_failed = False + def __init__(self, file: str, file_encoding: str, debug_mode: bool = False) -> None: """ defines an Editor object. @@ -621,11 +623,16 @@ def open(cls, file: str, file_encoding: str, write_func, on_windows_os: bool, (bool): indicates whether or not the editor has written any content to the provided files """ + if Editor.loading_failed: + return False + if CURSES_MODULE_ERROR: print("The Editor could not be loaded. No Module 'curses' was found.", file=sys.stderr) if on_windows_os: print('If you are on Windows OS, try pip-installing ', end='', file=sys.stderr) print("'windows-curses'.", file=sys.stderr) + print(file=sys.stderr) + Editor.loading_failed = True return False # if not (sys.stdin.isatty() | sys.stdout.isatty()): # print("The Editor could not be loaded.", file=sys.stderr)