Пример #1
0
 def display_values(values_list, sentence):
     for ind, elmt in enumerate(values_list):
         print(ind + 1, " - ", end="")
         elmt = elmt[1:]
         print(elmt, sep=", ")
     choice = Check.check_choice_list(values_list, sentence)
     return choice
 def choice_list(great_category=None, category=None, rank=1, food=False):
     with open("list_categories.json", 'r') as categories_file:
         categories_list = json.load(categories_file)
     select_list = categories_list
     if categories_list and rank == 1:
         cate_name = 'grande catégorie'
         select_list = list(categories_list.keys())
     elif (rank == 2) and (not food):
         cate_name = 'categorie'
         select_list = categories_list[great_category]
     elif (rank == 2) and food:
         cate_name = 'categorie'
         select_list = list(categories_list[great_category].keys())
     elif rank == 3:
         cate_name = 'sous-categorie'
         select_list = categories_list[great_category][category]
     if select_list:
         Display.display(select_list)
         choice = Check.check_choice_list(
             select_list,
             "choisssez une %s dans la liste ou bien ajoutez une nouveauté ( tapez n ): "
             % cate_name)
         print("le choice des cates dans categories: ", choice)
     if (not select_list) or (choice == 'n'):
         choice = Categories.create(categories_list=categories_list,
                                    great_category=great_category,
                                    category=category,
                                    rank=rank)
     return choice
Пример #3
0
 def display_menu(menu, sentence):
     list_menu = list()
     if menu == "first":
         list_menu = __class__.LIST_FIRST_MENU
     elif menu == "second":
         list_menu = __class__.FALSE_PURCHASE_LIST
     Display.display(list_menu)
     choice = Check.check_choice_list(list_menu, sentence)
     return choice
Пример #4
0
 def change_code(card_code, list_card_code):
     Display.display_dict(list_card_code)
     name = Check.check_choice_list(
         list(list_card_code.keys()),
         "le nom de la pesonne à qui appartient le code: ")
     list_status = ["compte perso", "compte commun"]
     Display.display(list_status)
     status = Check.check_choice_list(list_status,
                                      "de quel compte s'agit-il ? ")
     compte = "commun" if status == "compte commun" else "perso"
     if list_card_code[name][compte]:
         Display.display(list_card_code[name][compte])
         code_to_remove = Check.check_choice_list(
             list_card_code[name][compte],
             "supprimez des numéros dans %s de %s: " % (status, name))
         list_card_code[name][compte].remove(code_to_remove)
     list_card_code[name][compte].append(str(card_code))
     with open("card_list_code.json", "w") as file:
         json.dump(list_card_code, file)
Пример #5
0
 def get_store(sentence):
     create = False
     store_name = input(sentence)
     store_list = Store.store_research(store_name)
     store_id = 0
     if not store_list:
         print("pas de magasins à ce nom")
     else:
         Display.display_store(store_list)
         store_choice = Check.check_choice_list(
             store_list,
             "choissez un nmagasin parmi la liste proposée ou bien quittez (q )"
         )
     if (not store_list) or (store_choice == 'q'):
         new_store = input("voulez-vous enregistrer ce magasin ? ")
         if new_store == 'o':
             store_id = Store.new_store()
     else:
         store_id = store_choice[0]
     return store_id