def show_statistics(player): statistics_keys = ("wins", "loss", 'discovered_boards') statistics_dict = {} for k in player: if k in statistics_keys: statistics_dict[k] = player[k] ui.print_table(statistics_dict)
def start_module(): """ Display menu and wait for user choice. """ handle_submenu() table = data_manager.get_table_from_file(file_name) inputs = ui.get_inputs(["Please choose your option"], " ") option = inputs[0] if option == "1": show_table(table) elif option == "2": add(table) elif option == "3": ui.print_table(table, table_structure) id_ = ui.get_inputs(["Enter id of record to delete"], "") remove(table, id_) elif option == "4": ui.print_table(table, table_structure) id_ = ui.get_inputs(["Enter id of record which you want to edit"], "") update(table, id_) elif option == "5": get_counts_by_manufacturers(table) elif option == "6": manufacturer = ui.get_inputs(["Provide a manufacturer"], "") get_average_by_manufacturer(table, manufacturer) elif option == "0": main.main() else: raise KeyError("There is no such option.")
def choose_data_analyser(data_analyser_menu_list): data_analyser_menu_active = True while data_analyser_menu_active is True: inputs = ui.get_inputs(["Please enter a number: "], "") option = inputs[0] if option == '1': ui.print_result(get_the_last_buyer_name(), 'Last buyer\'s name ') elif option == '2': ui.print_result(get_the_last_buyer_id(), 'Last buyer\'s ID ') elif option == '3': ui.print_result(get_the_buyer_name_spent_most_and_the_money_spent(), '') elif option == '4': ui.print_result(get_the_buyer_id_spent_most_and_the_money_spent(), '') elif option == '5': frequent_buyers_number = int(ui.get_inputs(['frequent buyers you want to see: '], 'Please input the number of top ')[0]) ui.print_result(get_the_most_frequent_buyers_names(frequent_buyers_number), 'Most frequent buyer(s) names, and number of sales: ') elif option == '6': frequent_buyers_number = int(ui.get_inputs(['frequent buyers you want to see: '], 'Please input the number of top ')[0]) ui.print_result(get_the_most_frequent_buyers_ids(frequent_buyers_number), 'Most frequent buyer(s) id(s), and number of sales: ') elif option == '7': year_in = int(ui.get_inputs(['enter starting year: '], 'Please')[0]) year_out = int(ui.get_inputs(['enter ending year: '], 'Please')[0]) ui.print_table(customer_keep_up_purchasing_power(year_in, year_out), ['monthly avg price', 'monthly in']) elif option == '0': data_analyser_menu_active = False
def update(table, id_): """ Updates specified record in the table. Ask users for new data. :param table: text file where are included some information. :param id_: id of a record to update :return: list of list with updated record """ searched_record = [record for record in table if id_ in record] ui.print_table(searched_record, title_list) searched_record = searched_record[0] # unpack from list of lists id_place = 1 # due to id in on the 0 position in list i = 0 while i < 1: user_input = input("What do you want change?").lower() if user_input in update_options: chosen_option = update_options.index(user_input) + id_place new_data = input("Actual " + user_input + ": " + searched_record[chosen_option] + "\nEnter new: ") searched_record[chosen_option] = new_data i += 1 else: ui.print_error_message("Provide correct value") data_manager.write_table_to_file(file_name, table=table) ui.print_table([searched_record], title_list) return table
def configuration(ctx): """ Show configuration variables """ t = [["Key", "Value"]] for key in ctx.bitshares.config: t.append([key, ctx.bitshares.config[key]]) print_table(t)
def update(table, unique_id, title_list): """ Updates specified record in the table. Ask users for new data. Args: table (list): list in which record should be updated id_ (str): id of a record to update Returns: list: table with updated record """ # your code ui.print_table(table, title_list) row_to_change = [] user_choice = input("ID of record to change: ") for row in table: if user_choice in row: row_to_change.append(row) row_to_change = row_to_change[0] print(row_to_change) table.remove(row_to_change) element_to_change = int(input("Number of element to change: ")) changed_element = str(input("Change element to: ")) element_to_change = element_to_change - 1 print(element_to_change) row_to_change[element_to_change] = changed_element table.append(row_to_change) print(table) return table
def start_searching_functions(): title = "Searching menu" commands = [ "Search for games by number of players", "Search by title", "Search by type", "Back to main menu" ] games_list_of_lists = file_handling.import_file(filename="games.csv") ui.print_menu(title, commands) chosen_option = ui.menu_handling(1, 4) while True: if chosen_option == 1: # Wyszukuje gry dla określonej liczby graczy os.system("clear") number = ui.get_input("Search for games for how many peaople?", ["Enter number of playing people"]) results = search_for_games_by_number_of_players( games_list_of_lists, number) ui.print_table(results) start_searching_functions() elif chosen_option == 2: # Wyszukuje grę na podstawie tytułu os.system("clear") search_by_title(games_list_of_lists) start_searching_functions() elif chosen_option == 3: # Wyszukuje grę danego typu os.system("clear") search_by_type(games_list_of_lists) start_searching_functions() elif chosen_option == 4: # Powrót do głównego menu main_program.main()
def start_module(): list_options = [ "Add new game.", "Remove game.", "Update game.", "Show table" ] title_list = ["ID", "Title", "Manufacturer", "Price", "In stock"] title = "Games store" exit_message = "Main menu" ui.print_menu(title, list_options, exit_message) inputs = ui.get_inputs(["Please enter a number: "], "") option = inputs[0] table = data_manager.get_table_from_file("store/games.csv") if option == "1": add(table) elif option == "2": ui.print_table(table, title_list) id_ = str(ui.get_inputs(["ID "], "Input ID of game to remove")) remove(table, id_) elif option == "3": id_ = str(ui.get_inputs(["ID "], "Input ID of game to update")) update(table, id_) elif option == "4": show_table(table) elif option == "5": main.main(table, id_) else: raise KeyError("There is no such list_options.")
def change_phonenumber(): cursor = conn.cursor() cursor.execute(""" UPDATE applicants SET phone_number = '003670/223-7459' WHERE first_name = 'Jemima' AND last_name = 'Foreman';""") cursor.execute(""" SELECT phone_number FROM applicants WHERE first_name = 'Jemima' AND last_name = 'Foreman';""") ui.print_table(cursor.fetchall(), ["Phone number"])
def show(positions): taken_seats = get_taken_seats()[0] #taken_seats[i] += len(students) ui.print_table( positions, ["ID", "Description", "Seats (Available/Taken)", "Company ID"], taken_seats)
def show_table(table): """ Display a table Args: table: list of lists to be displayed. Returns: None """ title_list = ['ID', 'NAME', 'YEAR', 'DKKS', 'IOIADS', 'DSA'] ui.print_table(table, title_list)
def show_nicelist(nice_list): """Show list of customers has subscribed newsletter""" to_print_list = [] for item in nice_list: item = str(item).split(';') item[0], item[1] = item[1], item[0] to_print_list.append(item) header = ['Name', 'email'] ui.print_table(to_print_list, header)
def randomwif(prefix, num): """ Obtain a random private/public key pair """ from bitsharesbase.account import PrivateKey t = [["wif", "pubkey"]] for n in range(0, num): wif = PrivateKey() t.append([str(wif), format(wif.pubkey, prefix)]) print_table(t)
def check_win_condition(game_map, win_zones): current_map = game_map for zone in win_zones: if current_map[zone[0]][zone[1]] not in "B": return True else: continue ui.print_table(current_map, {}) print("You Win!!") start.os.sys.exit(0)
def delete_user(): cursor = conn.cursor() cursor.execute("""DELETE FROM applicants WHERE email LIKE '*****@*****.**';""") cursor.execute("""SELECT * FROM applicants ORDER BY id;""") details = [ "ID", "First name", "Last name", "Phone number", "Email address", "Application Code" ] ui.print_table(cursor.fetchall(), details)
def show_table(table): """ Display a table Args: table: list of lists to be displayed. Returns: None """ labels = ['ID', 'Full ID', 'Name', 'Year'] ui.print_table(table, labels)
def show_table(table): """ Display a table Args: table (list): list of lists to be displayed. Returns: None """ ui.print_table(table, ["id", "name", "birth_year"]) #, "price", "in stock"])
def show_table(table): """ Display a table Args: table: list of lists to be displayed. Returns: None """ title_list = ["id", "name", "email", "subscribed"] ui.print_table(table, title_list)
def show_table(table): """ Display a table Args: table (list): list of lists to be displayed. Returns: None """ ui.print_table(table, LIST_OF_TITLES)
def start_module(): """ 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 """ menu_list = ['Show table', 'Add game to inventory', 'Remove game from inventory', 'Update data for game', 'Available items', 'Average durability by manufacturers'] file_name = 'inventory/inventory.csv' error_message = 'Select number from 0 to 6, pointing the action you want to be done' title = 'Inventory' table = data_manager.get_table_from_file(file_name) stay = True while stay: ui.print_menu(title, menu_list, 'Back to main menu') task_selection = ui.get_inputs([''], 'Please enter a number:') while not common.is_selection_proper(task_selection, len(menu_list)): ui.print_error_message(error_message) task_selection = ui.get_inputs([''], 'Please enter a number:') if task_selection[0] == '1': show_table(table) elif task_selection[0] == '2': table = add(table) elif task_selection[0] == '3': id_ = ask_for_id(table, 'Please enter an id of game to remove:') table = remove(table, id_) elif task_selection[0] == '4': id_ = ask_for_id(table, 'Please enter an id of game to be updated:') update(table, id_) elif task_selection[0] == '5': ui.print_table(get_available_items(table), ['id', 'name of game', 'company', 'year of realise', 'durability']) elif task_selection[0] == '6': ui.print_result(get_average_durability_by_manufacturers(table), 'average durability by manufacturers ') else: stay = False
def show_table(table): """ Display a table Args: table (list): list of lists to be displayed. Returns: None """ ui.print_table(table, ["ID", "TITLE", "MANUFACTURER", "PRICE", "IN STOCK"])
def show_table(table): """ Display a table Args: table (list): list of lists to be displayed. Returns: None """ ui.print_table(table, ["id", "month", "day", "year", "type", "amount"])
def show_table(table): """ Display a table Args: table (list): list of lists to be displayed. Returns: None """ ui.print_table(table, table_structure())
def show_table(table): """ Display a table Args: table (list): list of lists to be displayed. Returns: None """ ui.print_table(table, ["id", "title", "manufacturer", "price", "in stock"])
def show_table(table): """ Display a table Args: table (list): list of lists to be displayed. Returns: None """ ui.print_table(table,["ID","Count1","Count2","Date","in/out","Sold"])
def show_table(table): """ Display a table Args: table (list): list of lists to be displayed. Returns: None """ ui.print_table(table, list_labels)
def show_table(table): """ Display a table Args: table (list): list of lists to be displayed. Returns: None """ ui.print_table(table, ['ID', 'month', 'day', 'year', 'type', 'amount'])
def show_table(sales_list): """ Display a table Args: table (list): list of lists to be displayed. Returns: None """ ui.print_table(sales_list, title_list)
def show_table(table): """ Display a table Args: table: list of lists to be displayed. Returns: None """ title_list = ['ID', 'NAME', 'MANUFACTURER', 'PURCHASE_DATE', 'DURABILITY'] ui.print_table(table, title_list)
def show_table(table): """ Display a table Args: table (list): list of lists to be displayed. Returns: None """ ui.print_table(table, ['id', 'title', 'price', 'month', 'day', 'year', 'sale id'])