From d650627710f3dafc4c8778673cf0706ea2de12e7 Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Fri, 27 Dec 2024 11:06:43 +0100 Subject: [PATCH] Added test if retired sets not existing --- app.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/app.py b/app.py index c4378c1..e09fa36 100644 --- a/app.py +++ b/app.py @@ -547,24 +547,27 @@ def wishlist(): cursor.close() conn.close() - retired_sets_dict = {} - - with open('retired_sets.csv', mode='r', encoding='utf-8') as csvfile: - reader = csv.reader(csvfile) - header = next(reader) - for row in reader: - key = row[2] - retired_sets_dict[key] = row - conn = sqlite3.connect('app.db') cursor = conn.cursor() cursor.execute('SELECT * from wishlist;') results = cursor.fetchall() wishlist = [list(i) for i in results] - for w in wishlist: - set_num = w[0].split('-')[0] - w.append(retired_sets_dict.get(set_num,[""]*7)[6]) + retired_sets_dict = {} + + try: + with open('retired_sets.csv', mode='r', encoding='utf-8') as csvfile: + reader = csv.reader(csvfile) + header = next(reader) + for row in reader: + key = row[2] + retired_sets_dict[key] = row + for w in wishlist: + set_num = w[0].split('-')[0] + w.append(retired_sets_dict.get(set_num,[""]*7)[6]) + except: + print('No retired list') + if wishlist == None or wishlist == '': wishlist = '' conn.commit()