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()