From 871ace3ba08c5cb11f86ba7e8ac33497a12fe693 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Tue, 15 Oct 2024 07:32:00 +0200 Subject: [PATCH] Fehlende Status-Datei akzeptieren --- main.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 98c7c2f..f283392 100644 --- a/main.py +++ b/main.py @@ -241,20 +241,24 @@ class Sesion: def abfrage(parser, quiero_unidad, otra_vez): random.seed() + status = {} + palabras = [] + os.makedirs(VOKABELN_DIR, exist_ok=True) try: - palabras = [] - os.makedirs(VOKABELN_DIR, exist_ok=True) - try: - os.rename(DEPRECATED_VOKABELN_FILE, os.path.join(VOKABELN_DIR, 'vokabeln.json')) - except FileNotFoundError: - pass + os.rename(DEPRECATED_VOKABELN_FILE, os.path.join(VOKABELN_DIR, 'vokabeln.json')) + except FileNotFoundError: + pass - for filename in glob.glob(os.path.join(VOKABELN_DIR, '*.json')): - with open(filename, 'r') as f: - palabras += json.load(f) + for filename in glob.glob(os.path.join(VOKABELN_DIR, '*.json')): + with open(filename, 'r') as f: + palabras += json.load(f) + try: with open(STATUS_FILE, 'r') as f: status = json.load(f) except FileNotFoundError: + pass + + if len(palabras) == 0: print(f"{bcolors.FAIL}Daten können nicht geladen werden, hast du sie schon importiert?{bcolors.ENDC}") print() parser.print_help()