-
Notifications
You must be signed in to change notification settings - Fork 0
/
console.py
183 lines (134 loc) · 4.01 KB
/
console.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
from main import Queue
from main import get_today_schedule, restack_today, get_lists, get_list
from main import remove_item_from_list, get_next_card, get_latest_item
from main import add_item as add_item_to_list, update_latest_item
urgencies = {
't': 'today_schedule',
'1': '1',
'2': '2',
'3': '3',
'4': '4'
}
def show_today():
today_schedule = get_today_schedule()
print("\n" + "-"*20)
print("| Today's Schedule |")
print("-"*20 + "\n")
if today_schedule.__len__() == 0:
print("Schdule is empty")
print("Restack and try again...")
else:
for item in today_schedule.queue:
print(item)
print("\n" + "*"*20 + "\n")
def add_item(item_name=None, new=False):
if not item_name:
item_name = input("Name: ")
if item_name in ['0', 'exit']:
print("Canceling...")
return
print("(1) / (2) / (3) / (4)")
urgency_choice = input(": ").lower()
match urgency_choice:
case '1' | '2' | '3' | '4':
try:
add_item_to_list(item_name, urgencies[urgency_choice], new)
except ValueError:
print("Item already exists in list")
case _:
print("Invalid choice")
return
def show_lists():
lists = get_lists()
for item in lists:
print(item)
def show_next():
today_schedule = get_today_schedule()
next_card = get_next_card()
if not next_card:
print("No next card")
return
print_line_in_box("Current Card: " + next_card)
input("Press Enter to continue...")
print("Add card to list")
add_item(next_card)
def show_latest():
latest_item = get_latest_item()
if latest_item:
print()
print_line_in_box("Latest added item")
print()
print(get_latest_item())
print("\n" + "*"*20 + "\n")
else:
print_line_in_box("No latest item found!")
def print_line_in_box(line: str):
length = line.__len__() + 10
print('-' * length)
print('|' + line.center(length - 2, ' ') + '|')
print('-' * length)
def advanced():
print("Advanced")
print("(R)emove item")
print("(CL) Change Latest item")
print("(M)ove item")
choice = input(": ").lower()
if choice in ['r', 'cl', 'm']:
show_lists()
list_choice = urgencies[input(
"(T) / (1) / (2) / (3) / (4): ").lower()]
list_items = get_list(list_choice)
if (len(list_items) == 0):
print_line_in_box("List is empty")
return;
for num, item in enumerate(list_items.queue, start=1):
print(f"{num}. {item}")
choice_num = int(input(": ")) - 1
match choice:
case 'r' | 'm':
try:
removed_item = remove_item_from_list(list_choice, choice_num)
except IndexError:
print_line_in_box("Invalid choice, no items removed")
case 'cl':
update_latest_item(list_items[choice_num])
if choice in ['m']:
print_line_in_box("Item to move: " + removed_item)
add_item(removed_item)
def main():
print("Quran Memoriation")
while True:
print('='*5 + "MENU" + '='*5)
print("1. Today")
print("2. Next")
print("3. Restack")
print("4. Add")
print("5. Lists")
print("6. Latest")
print("0. Exit")
print("-"*14)
print("9.advanced")
choice = int(input(": "))
match choice:
case 1:
show_today()
case 2:
show_next()
case 3:
restack_today()
case 4:
add_item(new=True)
case 5:
show_lists()
case 6:
show_latest()
case 9:
advanced()
case 0:
break
case _:
print("Invalid choice")
input("Press Enter to continue...")
print('-'*20)
if __name__ == '__main__':
main()