forked from FrederikBaerentsen/BrickTracker
Added retirement info to wishlist
This commit is contained in:
14
app.py
14
app.py
@@ -5,7 +5,7 @@ from flask_socketio import SocketIO
|
||||
from threading import Thread
|
||||
from pprint import pprint as pp
|
||||
from pathlib import Path
|
||||
import time,random,string,sqlite3
|
||||
import time,random,string,sqlite3,csv
|
||||
import numpy as np
|
||||
import re #regex
|
||||
import rebrick #rebrickable api
|
||||
@@ -547,12 +547,24 @@ 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])
|
||||
if wishlist == None or wishlist == '':
|
||||
wishlist = ''
|
||||
conn.commit()
|
||||
|
||||
Reference in New Issue
Block a user