-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfirmation.py
More file actions
53 lines (48 loc) · 1.74 KB
/
confirmation.py
File metadata and controls
53 lines (48 loc) · 1.74 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
#===================================Libraries====================================
from ui import custom_time, clear, YELLOW, GREEN, RESET
#================================================================================
import os
#---------------------------------------------------------------
#Present the user's task in an organized manner
def display_task(user_task):
print("\n ====Confirm Task====\n\n")
print(" ^Task Preview^\n")
for key, value in user_task.items():
print(YELLOW + f"{key:14}" + RESET + ":", GREEN + f"{value}" + RESET)
print("=" * 30, "\n")
def confirm_action(message):
try:
confirm = input(f"{message} y/n: ").lower()
custom_time(.3)
clear()
if confirm in ['y', 'yes', 'yea', 'ya']:
return 'yes'
elif confirm in ['n', 'no']:
return 'no'
else:
print("You can only enter yes or no. (y, n).")
custom_time(1.5)
return False
except:
print("You can only enter a text value.")
custom_time(1.5)
return False
def confirm_task(user_task):
while True:
display_task(user_task)
confirm = confirm_action(GREEN + "Save this task?" + RESET)
if not confirm:
clear()
continue
elif confirm == "yes":
print(GREEN + "Task has been confirmed." + RESET)
custom_time(.8)
clear()
return True
else:
print(GREEN + "This task will be ignored." + RESET)
custom_time(1.1)
clear()
return False
#---------------------------------------------------------------
print(os.path.abspath(__file__))