-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
345 lines (294 loc) · 12.6 KB
/
main.py
File metadata and controls
345 lines (294 loc) · 12.6 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
#===================================Libraries====================================
from logic import Task, User, is_valid_num, is_valid_title, is_valid_time, is_valid_status
from logic import is_user_available, has_task, ask_for_data
from file_logic import read_task_file_if_true, read_user_file_if_true
from search_logic import search_for_title, search_for_time, search_for_status, do_custom_search, search_by_number
from ui import custom_time, clear, loading, wait_user, RED, GREEN, BLUE, YELLOW, RESET
#================================================================================
clear()
user_task = Task(None, None, None)
user_info = User(None, None, None, None)
user_task.read_tasks_file()
user_info.read_user_file()
user_task.save_tasks()
user_info.save_user()
loading("Please wait ", 3, "", 0)
time_show = 1
important_edit = False
read_user_file = True
#================================================================================
user_info = ask_for_data(user_info)
#================================================================================
while True:
clear()
if isinstance(user_info.age, int):
if user_info.age < 7:
print(RED + "Sorry, you are under the age limit, which is 7 years and above." + RESET)
exit()
if not user_info.name:
print("\nwelcome in to-do-list program\n\n".upper())
else:
if time_show == 1:
user_info.say_welcome()
print("How can we help you?\n")
#FIRST PART
print(BLUE + " ---task help:" + RESET)
print(YELLOW + " 1) Add a task." + RESET)
print(" 2) Update a task.")
print(RED + " 3) Delete a task." + RESET)
print(" 4) See my list.")
print(GREEN + " 5) Mark as Completed.\n" + RESET)
#MIDDEL PART
print(BLUE + " ---info help:" + RESET)
print(YELLOW + " 6) Add my info." + RESET)
print(" 7) See my info.")
print(RED + " 8) Change my info.\n" + RESET)
#LAST PART
print(BLUE + " ---exit & search:" + RESET)
print(GREEN + " 9) Search." + RESET)
print(RED + " 10) Exit.\n" + RESET)
if important_edit:
help_with = '8'
else:
help_with = is_valid_num(10, "help")
if not help_with: continue
#===============Verify files=================
time_show += 1
user_task.read_tasks_file()
user_info.read_user_file()
it_has_wrong_task = read_task_file_if_true()
if it_has_wrong_task:
task_numbers = []
for n in it_has_wrong_task:
n += 1
task_numbers.append(str(n))
print(RED + f"Sorry, task number {', '.join(task_numbers)} gaveing with a wrong value!\nPlease edit\delete task." + RESET)
custom_time(3.5)
while True:
try:
clear()
edit_delete = input("Type edit/delete: ").lower()
if edit_delete in ["edit", "e", "ed"]:
clear()
custom_time(0.5)
user_task.update_task(task_numbers)
break
elif edit_delete in ["delete", "d", "de"]:
clear()
custom_time(0.5)
user_task.delete_task()
break
else:
print("Type only from the options.")
custom_time(1.5)
except:
print("Something went wrong! try again.")
custom_time(1.5)
continue
continue
if read_user_file:
it_has_wrong_info = read_user_file_if_true()
if it_has_wrong_info:
print(RED + "Dear user, there's wrong in your:" + RESET)
for num, all_worngs in enumerate(it_has_wrong_info):
print(f"{num+1}. ",all_worngs)
custom_time(.5)
custom_time(3)
clear()
print(GREEN + "We will send you to the edit page to edit your data." + RESET)
important_edit = True
read_user_file = False
custom_time(3)
continue
#============================================
#---------------------------------------------
#add task
if help_with == '1':
user_task_title = is_valid_title(text="new", similar=True)
custom_time(.8)
user_task_time = is_valid_time(use_last_time=True, similar=True)
if user_task_time == "wrong":
continue
custom_time(.8)
user_task_status = is_valid_status(mark=False)
user_task.add_task(user_task_title, user_task_time, user_task_status)
user_task.save_tasks()
continue
#update task
elif help_with == '2':
user_task.update_task(wrong_time=0)
#delete task
elif help_with == '3':
user_task.delete_task()
#show list tasks
elif help_with == '4':
if not user_task.show_tasks(True): continue
wait_user()
continue
#mark task
elif help_with == '5':
user_task.mark_tasks()
#---------------------------------------------
#add user info
elif help_with == '6':
if user_info.name:
print(BLUE + f"Dear user {user_info.name}, You've added your info actually." + RESET)
custom_time(2.2)
continue
user_info = ask_for_data(user_info)
#print user info
elif help_with == '7':
if not is_user_available(user_info): continue
user_info.show_user_info()
custom_time(5.5)
#change user info
elif help_with == '8':
if not is_user_available(user_info): continue
important_edit = False
read_user_file = True
while True:
clear()
print("\nI want change my:\n")
print(" 1) Name.")
print(YELLOW + " 2) Age/Birth." + RESET)
print(" 3) Gender.")
print(RED + " 4) Nothing.\n" + RESET)
change = is_valid_num(4, "change")
if not change: continue
if change == '4': break
if change == '1':
user_info.change_user_info("new_name")
loading("Updating your name ", 4, f"Your name has update to {user_info.name}.", 2)
elif change == '2':
user_info.change_user_info("new_age")
loading("Updating your age ", 6, f"Your age has update to {user_info.age}, And your birth to {user_info.date_birth}", 2.8)
elif change == '3':
user_info.change_user_info("new_gender")
loading("Updating your gender ", 4, f"Your gender has update to {user_info.gender}.", 2)
else:
print("sorry, someting went wrong! try again.")
custom_time(1.5)
continue
#---------------------------------------------
#search
elif help_with == '9':
data_available = has_task()
if not data_available: continue
while True:
clear()
print("\nI want to search for:\n")
print(" 1) Title task/s.")
print(" 2) Time task/s.")
print(" 3) Status task/s.")
print(YELLOW + " 4) Comprehensive/Customized Search." + RESET)
print(YELLOW + " 5) By task number." + RESET)
print(RED + " 6) Nothing.\n" + RESET)
try:
search_for = is_valid_num(6, "search")
if not search_for: continue
#title search
if search_for == '1':
title_search = is_valid_title("searching", similar=False)
if not title_search: continue
search = search_for_title(title_search)
custom_time(.5)
if not search:
print("Sorry, we couldn't find a similar task.")
custom_time(1.5)
print("Or you can view your task list to confirm the name of the task you want,\nThen try again.")
custom_time(2.8)
continue
if search:
wait_user()
continue
#time search
elif search_for == '2':
time_search = is_valid_time(True, False)
if not time_search: continue
if len(time_search) > 4:
time_search = time_search[11:]
search = search_for_time(time_search)
custom_time(.5)
if not search:
print("Sorry, we couldn't find a similar task.")
custom_time(1.5)
print("Or make sure to check your task list first.")
custom_time(2)
continue
if search:
wait_user()
continue
#status search
elif search_for == '3':
status_search = is_valid_status(False)
if not status_search: continue
search = search_for_status(status_search)
custom_time(.5)
if not search:
print("Sorry, we couldn't find a similar task.")
custom_time(1.5)
print("Or make sure to type only (completed/not yet), and try again.")
custom_time(1.9)
continue
if search:
wait_user()
continue
#custom Search
elif search_for == '4':
while True:
title_search = is_valid_title("searching", similar=False)
if not title_search: continue
time_search = is_valid_time(True, False)
if not time_search: continue
if len(time_search) > 4:
time_search = time_search[11:]
status_search = is_valid_status(False)
if not status_search: continue
search = do_custom_search(title_search, time_search, status_search)
custom_time(.5)
if not search:
print("Sorry, we couldn't find a similar task.")
custom_time(1.5)
continue
if search:
wait_user()
break
continue
#search by task number
elif search_for == '5':
try:
clear()
num = int(input("Type task number: "))
custom_time(.3)
clear()
if num <= 0:
print("The task number cannot be zero or less.")
custom_time(1.5)
continue
if num > 0:
search = search_by_number(num)
if not search:
print(f"Sorry, we couldn't find a similar task has number {num}.")
custom_time(1.9)
continue
else:
wait_user()
except:
print("Enter only a whole number that is not equal to zero.")
custom_time(1.5)
continue
#exit
elif search_for == '6': break
else:
print("\nInvalid input. enter a value from options.")
custom_time(1.5)
continue
except:
print("\nSorry, something went wrong! try again.")
custom_time(1.2)
continue
#exit...
elif help_with == '10':
loading("Exiting ", 5, "See you again❤️", 1)
break
#======================================================================end===============================================================