-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
89 lines (67 loc) · 2.52 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import database
import reports
import images
import prompts
import google_sheet
def add_new_cards():
if input(prompts.UPDATE_FROM_CSV) == 'y':
google_sheet.update_db_from_sheet(cards=True)
else:
pass
def add_new_memorabilia():
if input(prompts.UPDATE_FROM_CSV) == 'y':
google_sheet.update_db_from_sheet(cards=False)
else:
pass
def add_images():
if input(prompts.ADD_IMAGE) == 'card':
path = input(prompts.IMAGE_PATH)
# need to get card, can do a search to get back id?
database.insert_card_image(path) # need to add cid
elif input(prompts.ADD_IMAGE) == 'mem':
path = input(prompts.IMAGE_PATH)
# need to get item, can do a search to get back id?
database.insert_memorabilia_image(path) # need to add mid
def print_results(results, result_type):
if result_type == "card":
for cid, collection_code, player, team, card_set, year, card_number, parallel in results:
outstr = f"{cid}: {player} {card_set} {card_number} {parallel} in Collection {collection_code}" \
if parallel != "NULL" else f"{cid}: {player} {card_set} {card_number} in Collection {collection_code}"
print(outstr)
elif result_type == "mem":
for mid, collection_code, item_name in results:
print(f"{mid}: {item_name} in Collection {collection_code}")
def search_prompt(search_type=None):
search_results = None
if search_type is None:
search_type = input(prompts.SEARCH_TYPE)
if search_type == 'card':
term = input(prompts.CARD_SEARCH_TERM)
search_results = database.search('card', term)
elif search_type == 'mem':
term = input(prompts.MEM_SEARCH_TERM)
search_results = database.search('mem', term)
if search_results is None:
print("No matches were found.")
else:
print_results(search_results, search_type)
def produce_report():
pass
# --- Main Menu ---
MENU_OPTIONS = {
"1": add_new_cards,
"2": add_new_memorabilia,
"3": add_images,
"4": search_prompt,
"5": produce_report
}
def menu():
while (selection := input(prompts.MENU_PROMPT)) != "6":
try:
MENU_OPTIONS[selection]()
except KeyError:
print("Invalid input selected. Please try again.")
if __name__ == "__main__":
database.create_tables()
#google_sheet.update_db_from_sheet(True)
menu()