コード例 #1
0
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", "* email", "* subscribed"]

    options = [
        "Add new record to table",
        "Remove a record with a given id from the table",
        "Update specified record in the table",
        "ID of the customer with the longest name",
        "Customers that have subscribed to the newsletter", "Print table"
    ]
    os.system('clear')
    file = "model/crm/customers.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)
            id_with_longest_name = crm.get_longest_name_id(table)
            os.system("clear")
            print("ID of the customer with the longest name: ",
                  id_with_longest_name)
            common.waiting()
            os.system("clear")
        elif choice == "5":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            subscribed_mails = crm.get_subscribed_emails(table)
            os.system("clear")
            print("Customers that have subscribed to the newsletter: ",
                  subscribed_mails)
            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.")
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", "* Month of the transaction", "* Day of the transaction",
        "* Year of the transaction", "* Type", "* Amount in USD"
    ]

    options = [
        "Add new record to table",
        "Remove a record with a given id from the table",
        "Update specified record in the table", "Year of the highest profit",
        "Average profit in a given year", "Print table"
    ]
    os.system('clear')
    file = "model/accounting/items.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)
            year_of_highest_profit = accounting.which_year_max(table)
            os.system("clear")
            print("Year of the highest profit:", year_of_highest_profit)
            common.waiting()
            os.system("clear")
        elif choice == "5":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            year = int(common.get_input("Enter year: "))
            print(accounting.avg_amount(table, year))
            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.")
コード例 #3
0
def run():
    """
Uruchamia ten moduł i wyświetla jego menu.
     * Użytkownik ma tutaj dostęp do domyślnych funkcji specjalnych.
     * Użytkownik może wrócić do głównego menu.

    Zwroty:
        Żaden
    """

    options = [
        "Add new record to table", "Remove a record", "Update a record",
        "Get oldest person in file",
        "Get closest person to average year in file", "Print table"
    ]

    title_list = ["*id", "person", "year"]
    os.system('clear')
    file = "model/hr/persons.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)
            oldest_person = hr.get_oldest_person(table)
            os.system("clear")
            print("The oldest persons in the file: ", oldest_person)
            common.waiting()
            os.system("clear")
        elif choice == "5":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            closest_to_average = hr.get_persons_closest_to_average(table)
            os.system("clear")
            print("Closest person to average year is:", closest_to_average)
            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.")
コード例 #4
0
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",
                  "* title",
                  "* price",
                  "* month of the sale",
                  "* day of the sale",
                  "* year of the sale",
                  "* id of customer"]

    options = ["Add new record to table",
               "Remove a record with a given id from the table",
               "Update specified record in the table",
               "ID of the item that was sold for the lowest price",
               "Items that are sold between two given dates",
               "Print table"]
    os.system('clear')
    file = "model/sales/sales.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)
            item_the_lowest_price = sales.get_lowest_price_item_id(table)
            os.system("clear")
            print("id of the item that was sold for the lowest price: ", item_the_lowest_price)
            common.waiting()
            os.system("clear")
        elif choice == "5":
            pass
        elif choice == "6":
            common.all_print_table(title_list, file)

        else:
            if choice != "0":
                terminal_view.print_error_message("There is no such choice.")
コード例 #5
0
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 of item", "* title", "* price", "* month of the sale",
        "* day of the sale", "* year of the sale", "* customer's id"
    ]

    # ! sign with a position is unfinished function but added in options
    # !8. Show the sale numbers of games for each customer-292
    # !11. Show the customer who spent the most and the amount spent-365"
    # !12. Show the customer's id who spent the most and the amount spent-376"
    # !13. Show the most frequent buyers-387
    # !14. Show the if of the most freuent buyers-

    options = [
        "Print table", "Get game title by id",
        "Show the most recently sold game",
        "Get the sum of games' prices by their id",
        "Get the customer's id by the id of a game",
        "Show ids of all customers who purchased games",
        "Show sale ids of all customers",
        "Show the owner of a recently sold game",
        "Show the owner's id of a recently sold game",
        "Show the most frequent buyers",
        "Show the ids of the most frequent buyers", "Get the customer by id"
    ]

    os.system('clear')
    file = "model/sales/sales.csv"
    choice = None
    while choice != "0":
        os.system('clear')
        terminal_view.print_predator()
        terminal_view.print_menu("What do you want to do:", options,
                                 "Back to main menu")
        choice = terminal_view.get_choice(options)

        if choice == "1":
            os.system("clear")
            common.all_print_table(title_list, file)

        elif choice == "2":
            os.system("clear")
            print("Get game title by id\n")
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            identification = common.get_input("Enter the id: ")
            print(sales.get_title_by_id_from_table(table, identification))
            common.waiting()
            os.system("clear")

        elif choice == "3":
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            most_recently_sold_game = sales.get_item_id_title_sold_last(table)
            print("The most recently sold game is: ")
            terminal_view.print_table([most_recently_sold_game],
                                      ["* id", "* title"])
            common.waiting()
            os.system("clear")

        elif choice == "4":
            os.system("clear")
            print("Get the sum of games' prices by their id\n")
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            item_ids = []
            x = True
            while x:
                add_id = common.get_input("Enter the id or 'x' to exit: ")
                if add_id == "x":
                    x = False
                item_ids.append(add_id)
            print(sales.get_the_sum_of_prices_from_table(table, item_ids))
            common.waiting()
            os.system("clear")

        elif choice == "5":
            os.system("clear")
            print("Get the customer's id by the id of a game\n")
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            sale_id = common.get_input("Enter the id of a game: ")
            print(sales.get_customer_id_by_sale_id_from_table(table, sale_id))
            common.waiting()
            os.system("clear")

        elif choice == "6":
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            ids_of_all_customers = sales.get_all_customer_ids_from_table(table)
            print("ids of all customers who purchased games:\n",
                  ids_of_all_customers)
            common.waiting()
            os.system("clear")

        elif choice == "7":
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            sale_ids_of_all_customers = sales.get_all_sales_ids_for_customer_ids_form_table(
                table)
            print("Sale ids of all customers:\n\n", sale_ids_of_all_customers)
            common.waiting()
            os.system("clear")

        elif choice == "8":
            file_name_sales = common.get_double_file(
                "Choose a file with sales: ")
            if file_name_sales == "":
                file_name_sales = file
            file_name_customer = common.get_double_file(
                "Choose a file with customers: ")
            if file_name_customer == "":
                file_name_customer = "model/crm/customers.csv"
            table_from_customers = common.get_table_from_file(
                file_name_customer)
            table_from_sales = common.get_table_from_file(file_name_sales)
            last_buyer = sales.get_the_last_buyer_name(table_from_customers,
                                                       table_from_sales)
            print("Owner of a recently sold game: ", last_buyer)
            common.waiting()
            os.system("clear")

        elif choice == "9":
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            last_buyer_id = sales.get_the_last_buyer_id(table)
            print("Owner's id of a recently sold game: ", last_buyer_id)
            common.waiting()
            os.system("clear")

        elif choice == "10":
            file_name_sales = common.get_double_file(
                "Choose a file with sales: ")
            if file_name_sales == "":
                file_name_sales = file
            file_name_customer = common.get_double_file(
                "Choose a file with customers: ")
            if file_name_customer == "":
                file_name_customer = "model/crm/customers.csv"
            table_from_customers = common.get_table_from_file(
                file_name_customer)
            table_from_sales = common.get_table_from_file(file_name_sales)
            the_most_frequent_buyers = sales.get_the_most_frequent_buyers_names(
                table_from_customers, table_from_sales, num=1)
            print("The most frequent buyers:\n", the_most_frequent_buyers)
            common.waiting()
            os.system("clear")

        elif choice == "11":
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            the_most_frequent_buyers_ids = sales.get_the_most_frequent_buyers_ids(
                table, num=1)
            print("ids of the most frequent buyers:\n",
                  the_most_frequent_buyers_ids)
            common.waiting()
            os.system("clear")

        elif choice == "12":
            os.system("clear")
            print("Get the customer by id\n")
            file_name = common.get_file()
            if file_name == "":
                file_name = "model/crm/customers.csv"
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(
                table, ["* id", "* name", "* email", "* subscribed"])
            identification = common.get_input("Enter the id: ")
            print(crm.get_name_by_id_from_table(table, identification))
            common.waiting()
            os.system("clear")

        else:
            if choice != "0":
                terminal_view.print_error_message("There is no such choice.\n")
                common.waiting()
コード例 #6
0
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
    """

    options = [
        "Add new record to table",
        "Remove a record with a given id from the table",
        "Update specified record in the table",
        "Number of different kinds of game that are available of each manufacturer",
        "Average amount of games in stock of a given manufacturer",
        "Print table"
    ]

    title_list = ["*id", "* title", "* manufacturer", "* price", "* in_stock"]
    os.system('clear')
    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)
        os.system('clear')
        if choice == "1":
            # to jest dzialajacy plik               model/store/games.csv
            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)
            terminal_view.print_table(table, title_list)
            record = terminal_view.get_inputs(title_list, "Enter data: ")
            table = store.add(table, record)
            common.write_table_to_file(file_name, table)
            os.system("clear")
            terminal_view.gprint('*** Record has been added ***')
            common.waiting()
            os.system("clear")
        elif choice == "2":
            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)
            terminal_view.print_table(table, title_list)
            id_ = common.get_input("Get id to removed: ")
            table = store.remove(table, id_)
            common.write_table_to_file(file_name, table)
            os.system("clear")
            terminal_view.gprint('*** Record has been removed ***')
            common.waiting()
            os.system("clear")
        elif choice == "3":
            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)
            terminal_view.print_table(table, title_list)
            id_ = common.get_input("Enter id to update: ")
            record = terminal_view.get_inputs(title_list, "Enter data: ")
            table = store.update(table, id_, record)
            common.write_table_to_file(file_name, table)
            os.system("clear")
            terminal_view.gprint('*** Record has been updated ***')
            common.waiting()
            os.system("clear")
        elif choice == "4":
            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)
            dictionary = store.get_counts_by_manufacturers(table)
            terminal_view.print_dictionary(
                "Number of different kinds of game that are" +
                "available of each manufacturer:", dictionary)
            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)
            terminal_view.print_table(table, title_list)
            manufacturer = common.get_input("Enter a manufacturer: ")
            print(store.get_average_by_manufacturer(table, manufacturer))
            common.waiting()
            os.system("clear")
        elif choice == "6":
            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)
            terminal_view.print_table(table, title_list)
            common.waiting()
            os.system("clear")

        else:
            if 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.")