-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
49 lines (34 loc) · 1.09 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
from ux import date_input, print_age
from logic import get_age, get_date_from_string
from strings import USER_DATE_INPUT_INSTRUCTION, USER_DATE_INPUT_ERROR
from choices import add_choice, init_choices, quit_choices
def calculate_age_handler():
"""
Calculates and prints age data
"""
user_age_as_string = date_input(
name="Birth date", instructionMessage=USER_DATE_INPUT_INSTRUCTION, errorMessage=USER_DATE_INPUT_ERROR)
user_age_date = get_date_from_string(user_age_as_string)
age_data = get_age(user_age_date)
print_age(age_data)
def quit_app_handler():
"""
Stops App choices
"""
quit_choices()
def prepare_choices():
"""
Sets app choices handlers
"""
add_choice(label="1", description="Calculate age",
handler=calculate_age_handler)
add_choice(label="q", description="Quit the app",
handler=quit_app_handler)
def init_app():
"""
Inits App
(Runs the choices)
"""
prepare_choices()
init_choices()
init_app() # app initialization