def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ table_headers = [ 'ID', 'Name', 'Manufacturer', 'Purchase Year', 'Durability' ] choice = None filename = 'model/inventory/inventory.csv' columns_headers = ['Name', 'Manufacturer', 'Purchase Year', 'Durability'] ask_information = "Please provide your personal information" common.print_art(0) while choice != "0": choice = terminal_view.get_submenu_choice([ 'Add', 'Remove', 'Update', "Items that have not exceeded their durability yet", "Average durability by manufactirers" ]) table = common.get_table_from_file(filename) if choice[0] == "1": common.clear_terminal() common.adding(table, table_headers, filename, columns_headers, ask_information) elif choice[0] == "2": common.clear_terminal() common.removing(table, table_headers, id, filename) elif choice == "3": common.clear_terminal() common.updating(table, table_headers, id, filename, columns_headers, ask_information) elif choice == "4": common.clear_terminal() terminal_view.print_table(table, table_headers) availible_items = inventory.get_available_items(table) terminal_view.print_result( "Items that have not exceeded their durability yet", availible_items) elif choice == "5": common.clear_terminal() terminal_view.print_table(table, table_headers) average_durability = inventory.get_average_durability_by_manufacturers( table) terminal_view.print_result("Average durability by manufactirers:", average_durability) elif int(choice) >= 6: common.clear_terminal() terminal_view.print_error_message("There is no such choice.")
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ # your code menu_inventory = [ "Print inventory list", "Add to inventory list", "Remove form inventory list", "Update record in inventory list", "Available items", "Average durability" ] title = ["ID", "Name", "Manufacturer", "Purchase_year", "Durability"] title_del = ["Input ID: "] choice = None while choice != "0": choice = terminal_view.get_choice(menu_inventory) if choice == "1": terminal_view.print_table(inventory.get_data(), title) if choice == "2": inventory.new_record( common.get_user_inp_record( terminal_view.get_inputs(title[1:], "")), "model/inventory/inventory.csv") if choice == "3": inventory.delete_record( inventory.get_data(), common.get_user_inp_record( terminal_view.get_inputs(title_del, "")), "model/inventory/inventory.csv") if choice == "4": inventory.update_record( inventory.get_data(), common.get_user_inp_record( terminal_view.get_inputs(title_del, "")), terminal_view.get_inputs(title[1:], ""), "model/inventory/inventory.csv") if choice == "5": terminal_view.print_result( str(inventory.get_available_items(inventory.get_data())), "Available items: ") if choice == "6": terminal_view.print_result( str( inventory.get_average_durability_by_manufacturers( inventory.get_data())), "Oldest persons: ")
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_of_inventory = inventory.get_data_to_list() # your code options = ["Add new record", "Remove a record", "Update record", "Display available items", "Get average durability by manufacturers", "Print Table"] title_list = ["ID", "CONSOLA", "PRODUCENT", "YEAR", "DURABILITY"] choice = None while choice != "0": choice = terminal_view.get_choice(options, "Back to main menu") if choice == "1": new_record = terminal_view.get_inputs(["Name: ", "Manufacturer: ", "Purchase year: ", "Durability: "], "Please enter value: ") new_record.insert(0, inventory.get_random_id(list_of_inventory)) list_of_inventory = inventory.add(list_of_inventory, new_record) elif choice == "2": id_of_record_to_remove = ask_untill_correct(list_of_inventory) list_of_inventory = inventory.remove(list_of_inventory, common.check_id_by_number(list_of_inventory, int(id_of_record_to_remove))) elif choice == "3": id_of_record_to_update = ask_untill_correct(list_of_inventory) updated_record = terminal_view.get_inputs(["Name: ", "Manufacturer: ", "Purchase year: ", "Durability: "], "Please enter value: ") list_of_inventory = inventory.update(list_of_inventory, common.check_id_by_number(list_of_inventory, int(id_of_record_to_update)), updated_record) elif choice == "4": available_items = inventory.get_available_items(list_of_inventory) terminal_view.print_result(available_items, "Available items") elif choice == "5": average_durability = inventory.get_average_durability_by_manufacturers(list_of_inventory) terminal_view.print_result(average_durability, "Average durability by manufacturers") elif choice == "6": terminal_view.print_table(list_of_inventory, title_list) elif choice == "0": inventory.export_list_to_file(list_of_inventory) else: terminal_view.print_error_message("There is no such choice.")
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ common.clear() title = 'Inventory menu' options = [ "Add new record to table", "Remove a record with a given id from the table.", "Updates specified record in the table.", "Which items have not exceeded their durability yet?", "What are the average durability times for each manufacturer?" ] exit_message = "Back to main menu" title_list = ["ID", "NAME", "MANUFACTURER", "PURCHASE YEAR", 'DURABILITY'] table = inventory.data_manager.get_table_from_file( 'model/inventory/inventory.csv') choice = None while choice != "0": terminal_view.print_table(table, title_list) choice = terminal_view.get_choice(title, options, exit_message) if choice == "1": record = terminal_view.get_inputs( title_list, 'Please add following informations :', table) updated_table = inventory.add(table, record) inventory.data_manager.write_table_to_file( 'model/inventory/inventory.csv', updated_table) common.exit_prompt() common.clear() elif choice == "2": id_ = terminal_view.get_inputs(['Id'], 'Please give ID to remove :', table) updated_table = inventory.remove(table, id_) inventory.data_manager.write_table_to_file( 'model/inventory/inventory.csv', updated_table) common.exit_prompt() common.clear() elif choice == "3": id_ = terminal_view.get_inputs(['Id'], 'Please give ID of changed line :', table) record = terminal_view.get_inputs( title_list, 'Please add following informations :', table) updated_table = inventory.update(table, id_, record) inventory.data_manager.write_table_to_file( 'model/inventory/inventory.csv', updated_table) common.exit_prompt() common.clear() elif choice == "4": label = "The items that have not exceeded their durability yet: " result = inventory.get_available_items(table) terminal_view.print_result(result, label) common.exit_prompt() common.clear() elif choice == "5": label = "What are the average durability times for each manufacturer?" result = inventory.get_average_durability_by_manufacturers(table) terminal_view.print_result(result, label) common.exit_prompt() common.clear() elif choice != 0: terminal_view.print_error_message("There is no such choice.")
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ title_list = [ "* ID", "* Name of item", "* Manufacturer", "* Year of purchase", "* Years it can be used" ] options = [ "Add new record to table", "Remove a record with a given id from the table", "Update specified record in the table", "Items that have not exceeded their durability yet", "Average durability for each manufacturer", "Print table" ] os.system('clear') file = "model/inventory/inventory.csv" choice = None while choice != "0": terminal_view.print_menu("What do you want to do: ", options, "Back to main menu") choice = terminal_view.get_choice(options) if choice == "1": common.all_add(title_list, file) elif choice == "2": common.all_remove(title_list, file) elif choice == "3": common.all_updates(title_list, file) elif choice == "4": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = file table = common.get_table_from_file(file_name) items_with_available_durability = inventory.get_available_items( table) os.system("clear") print("Items that have not exceeded their durability:\n", items_with_available_durability) common.waiting() os.system("clear") elif choice == "5": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = "model/store/games.csv" table = common.get_table_from_file(file_name) average_durability = inventory.get_average_durability_by_manufacturers( table) os.system("clear") print("Average durability times for each manufacturer:\n", average_durability) common.waiting() os.system("clear") elif choice == "6": common.all_print_table(title_list, file) else: if choice != "0": terminal_view.print_error_message("There is no such choice.")