-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
101 lines (80 loc) · 2.45 KB
/
main.py
File metadata and controls
101 lines (80 loc) · 2.45 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
import requests
from Product import *
from constants import *
from api_requests import *
from database import *
import mysql.connector
import sys
usergf = MAIN_USER
hostgf = MAIN_HOST
passwrdgf = MAIN_PASSWORD
databasegf = MAIN_DATABASE
def logging():
"""First user screen"""
loop = 1
while loop:
choice = int(
input(
"1 - Nouvel utilisateur : Créer la base de données.\n"
"2 - Utilisateur existant : Poursuivre. \n"
"3 - Quitter le programme. \n"
)
)
if choice == 1:
Database.create_database()
print("Base de données créée.")
second_screen()
if choice == 2:
Database.loging()
print("Connecté à la base de données.")
second_screen()
if choice == 3:
loop = 0
sys.exit(0)
def second_screen():
"""Second user screen"""
loop = 1
while loop:
choice = int(
input("Mettre à jour les catégories et produits ? 1 = Oui // 2 = Non \n")
)
if choice == 1:
get_data()
main_screen()
if choice == 2:
main_screen()
def main_screen():
"""Main user screen"""
new_user = Database()
p_selected = Products()
loop = 1
while loop:
choice = int(
input(
"1 - Substituer un aliment. \n"
"2 - Accéder aux aliments substitués. \n"
"3 - Quitter le programme. \n"
)
)
if choice == 3:
loop = 0
sys.exit(0)
if choice == 1:
Database.display_categories(new_user)
cat_id = (int(input("Choisissez la catégorie: \n")),)
Database.select_category(new_user, cat_id)
product_id = int(input("Choissez un produit à substituer: \n"))
p_selected.get_product(product_id)
print("vous avez seléctionné: \n")
p_selected.display()
print("Ce produit a été substitué par : \n")
p_selected.substitute()
choice = input("Voulez-vous sauvegarder ce produit ? 1 = Oui // 2 = Non \n")
if choice == "1":
p_selected.save()
if choice == "2":
print("Sauvegarde non effectuée.")
if choice == 2:
Database.display_saved(p_selected)
if __name__ == "__main__":
logging()