コード例 #1
0
def add(table):
    """
    Asks user for input and adds it into the table.

    Args:
        table (list): table to add new record to

    Returns:
        list: Table with a new record
    """
    common.add("store/games.csv", table, ["Title of the game: ", "Manufacturer: ", "Price: ", "In stock: "])
    return table
コード例 #2
0
ファイル: hr.py プロジェクト: annapakula/lightweight-erp-py
def add(table):
    """
    Asks user for input and adds it into the table.

    Args:
        table (list): table to add new record to

    Returns:
        list: Table with a new record
    """
    common.add("hr/persons.csv", table, ["Enter name: ", "Enter birth_year: "])
    return table
コード例 #3
0
def step(ship, n):
    key, value = n
    if key == 'L':
        ship = (ship[0], ship[1] + value)
    elif key == 'R':
        ship = (ship[0], ship[1] - value)
    elif key == 'F':
        r = np.deg2rad(ship[1])
        ship = (add(ship[0], (np.cos(r) * value, math.sin(r) * value)), ship[1])
    else:
        d = dirmap[key]
        ship = (add(ship[0], (d[0] * value, d[1] * value)), ship[1])
    return ship
コード例 #4
0
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
    """

    # your code
    while True:
        
        title = "Inventory module"
        exit_message = "Exit to main"
        options = ["Show table",
                    "Add item",
                    "Remove item",
                    "Update item",
                    "Available items",
                    "Avg durability by manufacturer"]
        ui.print_menu(title, options, exit_message)

        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "/home/frojim/Documents/CC/lightweight-erp-python-extremely-random-programmers/inventory/inventory.csv"
        table = data_manager.get_table_from_file(file_name)
        title_list = ['id', 'title', 'manufacturer', 'purchase_year', 'durability']
        questions_asked = ['title: ', 'manufacturer: ', 'purchase_year: ', 'durability: ']
        unique_id = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, questions_asked)
        elif option == "3":
            common.remove(table, unique_id, title_list)
        elif option == "4":
            common.update(table, unique_id, title_list)
        elif option == "5":
            get_available_items(table, year)
        elif option == "6":
            get_average_durability_by_manufacturers(table)
        elif option == "0":
            break




    return table
コード例 #5
0
def attention(tensor, att_tensor, n_filters=512, kernel_size=1):
    g1 = Conv2D(n_filters,
                kernel_size=kernel_size,
                activation=None,
                strides=1,
                padding='same')(tensor)
    g1 = BatchNormalization()(g1)
    g1 = Activation('relu')(g1)

    x1 = Conv2D(n_filters,
                kernel_size=kernel_size,
                activation=None,
                strides=1,
                padding='same')(att_tensor)
    x1 = BatchNormalization()(x1)
    x1 = Activation('relu')(x1)

    net = C.add(g1, x1)
    #net = relu(net)
    net = Conv2D(1,
                 kernel_size=kernel_size,
                 activation=None,
                 strides=1,
                 padding='same')(net)
    net = BatchNormalization()(net)
    net = Activation('sigmoid')(net)

    net = C.multiply(net, att_tensor)
    return net
コード例 #6
0
def step2(pts, n):
    ship, way = pts
    key, value = n
    if key == 'L':
        way = rotate_around_pt(ship, way, value)
    elif key == 'R':
        way = rotate_around_pt(ship, way, -value)
    elif key == 'F':
        v = list(sub(way, ship))
        vs = [v] * value
        ship = list(reduce(lambda acc, n: add(acc, n), vs, ship))
        way = add(ship, v)
    else:
        d = dirmap[key]
        way = list(add(way, (d[0] * value, d[1] * value)))
    return ship, way
コード例 #7
0
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
    """
    while True:
        title = "Sales manager"
        exit_message = "(0) Back to main menu"
        list_options = [
            "(1) Show table", "(2) Add", "(3) Remove", "(4) Update",
            "(5) Cheapo game", "(6) Items sold between", "(7) Get title by ID",
            "(8) Get item ID sold last"
        ]
        ui.print_menu(title, list_options, exit_message)

        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "sales/sales.csv"
        title_list = ["id", "title", "price", "month", "day", "year"]
        table = data_manager.get_table_from_file(file_name)
        list_titles = ["month: ", "day: ", "year: ", "type: ", "amount: "]
        id_ = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, list_titles, file_name)
        elif option == "3":
            common.remove(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "4":
            common.update(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "5":
            get_lowest_price_item_id(table)
        elif option == "6":
            get_items_sold_between(table, month_from, day_from, year_from,
                                   month_to, day_to, year_to)
        elif option == "7":
            get_title_by_id_from_table(table, ui.get_inputs(["ID: "], "")[0])
        elif option == "8":
            get_item_id_sold_last(table)
        elif option == "0":
            break
コード例 #8
0
ファイル: hr.py プロジェクト: frojim/ERP
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
    """

    # your code

    while True:

        title = "Human resources module"
        exit_message = "Exit to main"
        options = [
            "Show table", "Add item", "Remove item", "Update item",
            "Oldest person", "Avg aged person"
        ]
        ui.print_menu(title, options, exit_message)

        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "/home/frojim/Documents/CC/lightweight-erp-python-extremely-random-programmers/hr/persons.csv"
        table = data_manager.get_table_from_file(file_name)
        title_list = ['id', 'name', 'birth_year']
        questions_asked = ['name: ', 'birth_year: ']
        unique_id = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, questions_asked)
        elif option == "3":
            common.remove(table, unique_id, title_list)
        elif option == "4":
            common.update(table, unique_id, title_list)
        elif option == "5":
            get_oldest_person(table)
        elif option == "6":
            get_persons_closest_to_average(table)
        elif option == "0":
            break
コード例 #9
0
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
    """

    # you code

    while True:

        title = "Accounting module"
        exit_message = "Exit to main"
        options = [
            "Show table", "Add item", "Remove item", "Update item",
            "Highest profit year", "Avg profit by item"
        ]
        ui.print_menu(title, options, exit_message)

        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "/home/frojim/Documents/CC/lightweight-erp-python-extremely-random-programmers/accounting/items.csv"
        table = data_manager.get_table_from_file(file_name)
        title_list = ['id', 'month', 'day', 'year', 'type', 'amount']
        questions_asked = ['month: ', 'day: ', 'year: ', 'type: ', 'amount: ']
        unique_id = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, questions_asked)
        elif option == "3":
            common.remove(table, unique_id, title_list)
        elif option == "4":
            common.update(table, unique_id, title_list)
        elif option == "5":
            which_year_max(table)
        elif option == "6":
            avg_amount(table, year)
        elif option == "0":
            break
コード例 #10
0
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
    """

    # your code

    while True:

        title = "Customer Relationship Management module"
        exit_message = "Exit to main"
        options = [
            "Show table", "Add item", "Remove item", "Update item",
            "Longest name", "Subscription"
        ]
        ui.print_menu(title, options, exit_message)

        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "/home/frojim/Documents/CC/lightweight-erp-python-extremely-random-programmers/crm/customers.csv"
        table = data_manager.get_table_from_file(file_name)
        title_list = ['id', 'name', 'email', 'subscribed']
        questions_asked = ['name: ', 'email: ', 'subscribed: ']
        unique_id = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, questions_asked)
        elif option == "3":
            common.remove(table, unique_id, title_list)
        elif option == "4":
            common.update(table, unique_id, title_list)
        elif option == "5":
            get_longest_name_id(table)
        elif option == "6":
            get_subscribed_emails(table)
        elif option == "0":
            break
コード例 #11
0
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
    """

    # your code
    while True:

        title = "Sales module"
        exit_message = "Exit to main"
        options = [
            "Show table", "Add item", "Remove item", "Update item",
            "Lowest priced item", "Items sold by date"
        ]
        ui.print_menu(title, options, exit_message)

        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "/home/frojim/Documents/CC/lightweight-erp-python-extremely-random-programmers/sales/sales.csv"
        table = data_manager.get_table_from_file(file_name)
        title_list = ['id', 'title', 'price', 'month', 'day', 'year']
        questions_asked = ["title: ", "price: ", "month: ", "day: ", "year: "]
        unique_id = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, questions_asked)
        elif option == "3":
            common.remove(table, unique_id, title_list)
        elif option == "4":
            common.update(table, unique_id, title_list)
        elif option == "5":
            get_lowest_price_item_id(table)
        elif option == "6":
            get_items_sold_between(table, month_from, day_from, year_from,
                                   month_to, day_to, year_to)
        elif option == "0":
            break
コード例 #12
0
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
    """

    while True:
        title = "Data analyser"
        exit_message = "(0) Back to main menu"
        list_options = ["(1) Last buyer name",
                        "(2) Last buyer ID",
                        "(3) Buyer name spent most and the money spent",
                        "(4) Buyer ID spent most and the money spent",
                        "(5) The most frequent buyers names",
                        "(6) The most frequent buyers IDs"]

        ui.print_menu(title, list_options, exit_message)
        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "crm/customers.csv"
        title_list = ["id", "name", "email", "subscribed"]
        table = data_manager.get_table_from_file(file_name)
        list_titles = ["name: ", "email: ", "subscriber (0/1): "]
        id_ = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, list_titles, file_name)
        elif option == "3":
            common.remove(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "4":
            common.update(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "5":
            get_oldest_person(table)
        elif option == "6":
            get_persons_closest_to_average(table)
        elif option == "0":
            break
コード例 #13
0
ファイル: store.py プロジェクト: frojim/ERP
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
    """
    while True:
        
        title = "Store module"
        exit_message = "Exit to main"
        options = ["Show table",
                    "Add item",
                    "Remove item",
                    "Update item",
                    "Games by manufacturers",
                    "Avg stock by manufacturer"]
        ui.print_menu(title, options, exit_message)

        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "/home/frojim/Documents/CC/lightweight-erp-python-extremely-random-programmers/store/games.csv"
        table = data_manager.get_table_from_file(file_name)
        title_list = ['id', 'title', 'manufacturer', 'price', 'in_stock']
        questions_asked = ['title: ', 'manufacturer: ', 'price: ', 'in_stock: ']
        unique_id = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, questions_asked)
        elif option == "3":
            common.remove(table, unique_id, title_list)
        elif option == "4":
            common.update(table, unique_id, title_list)
        elif option == "5":
            get_average_by_manufacturer(table, manufacturer)
        elif option == "6":
            get_counts_by_manufacturers(table)
        elif option == "0":
            break
コード例 #14
0
def add(table):
    """
    Asks user for input and adds it into the table.

    Args:
        table (list): table to add new record to

    Returns:
        list: Table with a new record
    """
    # unique_id = common.generate_random(table)
    # inputs = ui.get_inputs(["Enter game title", "Enter price: ", "Enter month of sale: ", "Enter day of sale: ", "Enter year of sale: "], "")
    # with open("sales/sales.csv", "a") as file:
    #     file.write(f"{unique_id};{';'.join(inputs)}\n")
    common.add("sales/sales.csv", table, [
        "Enter game title", "Enter price: ", "Enter month of sale: ",
        "Enter day of sale: ", "Enter year of sale: "
    ])
    return table
コード例 #15
0
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
    """
    while True:
        title = "CRM manager"
        exit_message = "(0) Back to main menu"
        list_options = [
            "(1) Show table", "(2) Add", "(3) Remove", "(4) Update",
            "(5) ID of longest name", "(6) subscribers",
            "(7) Customer name by ID"
        ]
        ui.print_menu(title, list_options, exit_message)

        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "crm/customers.csv"
        title_list = ["id", "name", "email", "subscribed"]
        table = data_manager.get_table_from_file(file_name)
        list_titles = ["name: ", "email: ", "subscriber (0/1): "]
        id_ = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, list_titles, file_name)
        elif option == "3":
            common.remove(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "4":
            common.update(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "5":
            get_longest_name_id(table)
        elif option == "6":
            get_subscribed_emails(table)
        elif option == "7":
            get_name_by_id_from_table(table, ui.get_inputs(["ID: "], "")[0])
        elif option == "0":
            break
コード例 #16
0
def add(table):
    """
    Asks user for input and adds it into the table.

    Args:
        table (list): table to add new record to

    Returns:
        list: Table with a new record
    """
    # unique_id = common.generate_random(table)
    # inputs = ui.get_inputs(["Enter item name", "Enter manufacturer: ", "Enter purchase year: ", "Enter durability (years): "], "")
    # with open("inventory/inventory.csv", "a") as file:
    #     file.write(f"{unique_id};{';'.join(inputs)}\n")
    common.add("inventory/inventory.csv", table, [
        "Enter item name", "Enter manufacturer: ", "Enter purchase year: ",
        "Enter durability (years): "
    ])
    return table
コード例 #17
0
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
    """
    while True:
        title = "Inventory manager"
        exit_message = "(0) Back to main menu"
        list_options = [
            "(1) Show table", "(2) Add", "(3) Remove", "(4) Update",
            "(5) Available items"
        ]
        ui.print_menu(title, list_options, exit_message)

        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "inventory/inventory.csv"
        title_list = [
            "id", "name", "manufacturer", "purchase year", "durability"
        ]
        list_titles = [
            "name: ", "manufacturer: ", "purchase year: ", "durability: "
        ]
        table = data_manager.get_table_from_file(file_name)

        id_ = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, list_titles, file_name)
        elif option == "3":
            common.remove(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "4":
            common.update(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "5":
            get_available_items(table)
        elif option == "0":
            break
コード例 #18
0
ファイル: crm.py プロジェクト: annapakula/lightweight-erp-py
def choose():
    table = data_manager.get_table_from_file("crm/customers.csv")
    inputs = ui.get_inputs(["Please enter a number: "], "")
    option = inputs[0]
    if option == "0":
        return False
    elif option == "1":
        common.show_table(table, ["ID", "name", "email", "subscribed"])
    elif option == "2":
        common.add(
            "crm/customers.csv", table,
            ["Enter name: ", "Enter email: ", "Subscription (1/0 = yes/no): "])
    elif option == "3":
        id_ = ui.get_inputs(["Please enter an ID: "], "")
        common.remove("crm/customers.csv", table, id_)
    elif option == "4":
        id_ = ui.get_inputs(["Please enter an ID of a record to update: "], "")
        common.update("crm/customers.csv", table, id_)

    start_module()
コード例 #19
0
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
    """
    while True:
        title = "HR manager"
        exit_message = "(0) Back to main menu"
        list_options = [
            "(1) Show table", "(2) Add", "(3) Remove", "(4) Update",
            "(5) Oldest Person", "(6) Age closest to average"
        ]
        ui.print_menu(title, list_options, exit_message)

        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "hr/persons.csv"
        title_list = ["id", "name", "birthyear"]
        table = data_manager.get_table_from_file(file_name)
        list_titles = ["name: ", "birth year: "]
        id_ = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, list_titles, file_name)
        elif option == "3":
            common.remove(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "4":
            common.update(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "5":
            get_oldest_person(table)
        elif option == "6":
            get_persons_closest_to_average(table)
        elif option == "0":
            break
コード例 #20
0
def add(table):
    """
    Asks user for input and adds it into the table.

    Args:
        table (list): table to add new record to

    Returns:
        list: Table with a new record
    """
    table = common.add(table, LIST_OF_TITLE)

    return table
コード例 #21
0
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
    """
    while True:
        title = "Storage manager"
        exit_message = "(0) Back to main menu"
        list_options = [
            "(1) Show table", "(2) Add", "(3) Remove", "(4) Update",
            "(5) Counts by manufacturers"
        ]
        ui.print_menu(title, list_options, exit_message)

        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "store/games.csv"
        title_list = ["id", "title", "manufacturer", "price", "stock"]
        list_titles = ["title: ", "manufacturer: ", "price: ", "stock: "]
        table = data_manager.get_table_from_file(file_name)
        id_ = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, list_titles, file_name)
        elif option == "3":
            common.remove(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "4":
            common.update(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "5":
            get_counts_by_manufacturers(table)
        elif option == "0":
            break
コード例 #22
0
def choose(menu):
    inputs = ui.get_inputs(["Please enter a number: "], "")
    option = inputs[0]
    if option == "1":
        show_table(
            ["Press ENTER to continue...", "Name", "E-mail", "Subscribed"],
            data_manager.get_table_from_file("crm/customers.csv"))
    elif option == "2":
        table = add(
            data_manager.get_table_from_file("crm/customers.csv"),
            ui.get_inputs([
                "Press ENTER to continue...", "Name: ", "E-mail: ",
                "Subscribed: "
            ], "Please provide the following information:"))
        data_manager.write_table_to_file("crm/customers.csv", table)
    elif option == "3":
        table = remove(
            data_manager.get_table_from_file("crm/customers.csv"),
            ui.get_inputs(["ID: "],
                          "Please provide the following information:"))
        data_manager.write_table_to_file("crm/customers.csv", table)
    elif option == "4":
        table = update(
            data_manager.get_table_from_file("crm/customers.csv"),
            ui.get_inputs(["ID"],
                          "Please provide the ID to identify the elemnt:"),
            ui.get_inputs([
                "ID", "Name", "E-mail", "Subscribed"
            ], "Please provide the following information to complete the update:"
                          ))
        data_manager.write_table_to_file("crm/customers.csv", table)
    elif option == "5":
        ui.print_result(
            get_longest_name_id(
                data_manager.get_table_from_file("crm/customers.csv")), "")
    elif option == "6":
        ui.print_result(
            get_subscribed_emails(
                data_manager.get_table_from_file("crm/customers.csv")), "")
    elif option == "7":
        ui.print_result(get_name_by_id("kH94Jc#&"), "")
    elif option == "8":
        pass

    elif option == "0":
        return False

    else:
        raise KeyError("There is no such option.")
    return True
コード例 #23
0
def choose(menu):
    file_name = "store/games.csv"
    inputs = ui.get_inputs(["Please enter a number: "], "")
    option = inputs[0]
    main_list = [
        "Press ENTER to continue...", "Title: ", "Manifacturer: ", "Price: ",
        "In_stock: "
    ]
    if option == "1":
        show_table(main_list, data_manager.get_table_from_file(file_name))
    elif option == "2":
        table = add(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(main_list,
                          "Please provide the following information:"))
        data_manager.write_table_to_file(file_name, table)
    elif option == "3":
        table = remove(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(["ID: "],
                          "Please provide the following information:"))
        data_manager.write_table_to_file(file_name, table)
    elif option == "4":
        table = update(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(["ID"],
                          "Please provide the ID to identify the elemnt:"),
            ui.get_inputs(
                main_list,
                "Please provide the following information to complete the update"
            ))
        data_manager.write_table_to_file(file_name, table)
    elif option == "5":
        ui.print_result(
            get_counts_by_manufacturers(
                data_manager.get_table_from_file(file_name)), "")
    elif option == "6":
        manufacturer = ui.get_inputs([
            "Manifacturer: "
        ], "To calculate the avg. amount please specify which manifacturer you want to select."
                                     )[0]
        ui.print_result(
            get_average_by_manufacturer(
                data_manager.get_table_from_file(file_name), manufacturer), "")
    elif option == "0":
        return False

    else:
        raise KeyError("There is no such option.")
    return True
コード例 #24
0
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"""
    while True:
        title = "Accounting manager"
        exit_message = "(0) Back to main menu"
        list_options = [
            "(1) Show table", "(2) Add", "(3) Remove", "(4) Update",
            "(5) Max profits"
        ]
        ui.print_menu(title, list_options, exit_message)

        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        file_name = "accounting/items.csv"
        title_list = ["id", "month", "day", "year", "type", "amount"]
        table = data_manager.get_table_from_file(file_name)
        list_titles = ["month: ", "day: ", "year: ", "type: ", "amount: "]
        id_ = ''

        if option == "1":
            common.show_table(table, title_list)
        elif option == "2":
            common.add(table, list_titles, file_name)
        elif option == "3":
            common.remove(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "4":
            common.update(table, ui.get_inputs(["ID: "], "")[0], file_name)
        elif option == "5":
            which_year_max(table)
        elif option == "0":
            break
コード例 #25
0
def choose(menu):
    file_name = "accounting/items.csv"
    inputs = ui.get_inputs(["Please enter a number: "], "")
    option = inputs[0]
    main_list = [
        "Press ENTER to continue...", "Month: ", "Day: ", "Year: ", "Type: ",
        "Amount: "
    ]
    if option == "1":
        show_table(main_list, data_manager.get_table_from_file(file_name))
    elif option == "2":
        table = add(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(main_list,
                          "Please provide the following information:"))
        data_manager.write_table_to_file(file_name, table)
    elif option == "3":
        table = remove(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(["ID: "],
                          "Please provide the following information:"))
        data_manager.write_table_to_file(file_name, table)
    elif option == "4":
        table = update(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(["ID"],
                          "Please provide the ID to identify the elemnt:"),
            ui.get_inputs(
                main_list,
                "Please provide the following information to complete the update"
            ))
        data_manager.write_table_to_file(file_name, table)
    elif option == "5":
        ui.print_result(
            which_year_max(
                data_manager.get_table_from_file("accounting/items.csv")), "")
    elif option == "6":
        s = int(ui.get_inputs("", ""))
        ui.print_result(
            avg_amount(
                data_manager.get_table_from_file("accounting/items.csv"), s),
            "")
    elif option == "0":
        return False

    else:
        raise KeyError("There is no such option.")
    return True
コード例 #26
0
def choose(menu):
    file_name = "sales/sales.csv"
    inputs = ui.get_inputs(["Please enter a number: "], "")
    option = inputs[0]
    main_list = [
        "Press ENTER to continue...", "Title: ", "Price: ", "Month: ", "Day: ",
        "Year: "
    ]
    if option == "1":
        show_table(main_list, data_manager.get_table_from_file(file_name))
    elif option == "2":
        table = add(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(main_list,
                          "Please provide the following information:"))
        data_manager.write_table_to_file(file_name, table)
    elif option == "3":
        table = remove(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(["ID: "],
                          "Please provide the following information:"))
        data_manager.write_table_to_file(file_name, table)
    elif option == "4":
        table = update(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(["ID"],
                          "Please provide the ID to identify the elemnt:"),
            ui.get_inputs(
                main_list,
                "Please provide the following information to complete the update"
            ))
        data_manager.write_table_to_file(file_name, table)
    elif option == "5":
        ui.print_result(
            get_lowest_price_item_id(
                data_manager.get_table_from_file(file_name)), "")
    elif option == "6":
        ui.print_result(
            get_items_sold_between(
                data_manager.get_table_from_file("sales/sales.csv"), 10, 1,
                2015, 12, 12, 2016)[1], "")
    elif option == "0":
        return False

    else:
        raise KeyError("There is no such option.")
    return True
コード例 #27
0
def choose(menu):
    file_name = "inventory/inventory.csv"
    inputs = ui.get_inputs(["Please enter a number: "], "")
    option = inputs[0]
    main_list = [
        "Press ENTER to continue...", "Name: ", "Manifacturer: ",
        "Purchase year: ", "Durability: "
    ]
    table = get_available_items(data_manager.get_table_from_file(file_name),
                                2006)
    if option == "1":
        show_table(main_list, data_manager.get_table_from_file(file_name))
    elif option == "2":
        table = add(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(main_list,
                          "Please provide the following information:"))
        data_manager.write_table_to_file(file_name, table)
    elif option == "3":
        table = remove(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(["ID: "],
                          "Please provide the following information:"))
        data_manager.write_table_to_file(file_name, table)
    elif option == "4":
        table = update(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(["ID"],
                          "Please provide the ID to identify the elemnt:"),
            ui.get_inputs(
                main_list,
                "Please provide the following information to complete the update:"
            ))
        data_manager.write_table_to_file(file_name, table)
    elif option == "5":
        list_of_items = [table[i][1] for i in range(len(table))]
        ui.print_result(list_of_items, "")
    elif option == "6":
        ui.print_result(
            get_average_durability_by_manufacturers(
                data_manager.get_table_from_file(file_name)), "")
    elif option == "0":
        return False

    else:
        raise KeyError("There is no such option.")
    return True
コード例 #28
0
def choose(menu):
    file_name = "hr/persons.csv"
    inputs = ui.get_inputs(["Please enter a number: "], "")
    option = inputs[0]
    main_list = ["Press ENTER to continue...", "Name: ", "Birth year: "]
    if option == "1":
        show_table(main_list, data_manager.get_table_from_file(file_name))
    elif option == "2":
        table = add(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(main_list,
                          "Please provide the following information:"))
        data_manager.write_table_to_file(file_name, table)
    elif option == "3":
        table = remove(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(["ID: "],
                          "Please provide the following information:"))
        data_manager.write_table_to_file(file_name, table)
    elif option == "4":
        table = update(
            data_manager.get_table_from_file(file_name),
            ui.get_inputs(["ID"],
                          "Please provide the ID to identify the elemnt:"),
            ui.get_inputs(
                main_list,
                "Please provide the following information to complete the update:"
            ))
        data_manager.write_table_to_file(file_name, table)
    elif option == "5":
        ui.print_result(
            get_oldest_person(data_manager.get_table_from_file(file_name)), "")
    elif option == "6":
        ui.print_result(
            get_persons_closest_to_average(
                data_manager.get_table_from_file(file_name)), "")
    elif option == "0":
        return False

    else:
        raise KeyError("There is no such option.")
    return True
コード例 #29
0
fname = 'day10.txt'
# fname = 'day10example_5.txt'
# fname = 'day10example_6.txt'

with open(fname) as f:
    map_ = [[c for c in line.strip()] for line in f]

mon = (26, 28)
# mon = (11, 13)
# mon = (8, 3)

w, h = len(map_[0]), len(map_)

lines = los(mon, map_)
# Put each line of sight into order, closest to monitoring station first
for line in lines:
    line.sort(key=dist_squared)
# Sort lines of sight by angle from vertically up
lines.sort(key=first_element_angle)

vaporized = []
while any([len(line) != 0 for line in lines]):
    for line in lines:
        try:
            vaporized.append(line.pop(0))
        except IndexError:
            pass

ans = add(vaporized[199], mon)
print(ans[0] * 100 + ans[1])
コード例 #30
0
ファイル: tests.py プロジェクト: koaning/makefile-demo
def test_add():
    assert add(1, 1) == 2