-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathask_questions.py
51 lines (42 loc) · 1.55 KB
/
ask_questions.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
from constant import *
from db import *
from gui import *
import codecs
randomChoice = False
''' asking helper functions '''
file = codecs.open('samples/test.txt', 'w', 'utf-8')
def Ask_Choices_Question(question: str, *choices) -> str:
return showAskAboutSymtomWindow(question, choices)
'''
function that ask question with list of choices to allow the user to choose from
'''
# // TODO make it in gui
try:
answer = input('{}\nchoices:\n{}\nanswer:'.format(
question,
'\n'.join(
map(lambda choice: f"{choice[0] + 1}) {choice[1]}", enumerate(choices)))
))
if not answer in choices:
answer = choice(choices)
raise IOError(f'wrong choice Try Again')
except IOError as error:
print(f'{B_COLORS.FAIL}ERROR: {error}{B_COLORS.ENDC}')
def Ask_Plant_Name() -> str:
result = Ask_Choices_Question(
'what is the plant to be diagnosed ?', *plants_Array)
file.write(result + '\n')
return result
def Ask_About_Symptom(question: str, symptom_Name, symptom_NameAr) -> float:
if randomChoice:
result = choice(list(CF_STRINGS.keys()))
# result = 'مطلقاً'
# result = 'لا'
# result = 'لست متأكدا'
# result = 'نعم ربما'
# result = 'نعم بالتاكيد'
else:
result = Ask_Choices_Question(question, *CF_STRINGS.keys())
file.write(symptom_NameAr + '\n')
file.write(result + '\n')
return CF_STRINGS[result]