Пример #1
0
def create_application(filename, filename_2, filename_3):
    table = file_handling.import_data(filename)  #import position table
    table_2 = file_handling.import_data(filename_2)  #import company table
    table_3 = file_handling.import_data(filename_3)  #import company table
    students_list = []
    for record in table_2:
        students_list.append(record[0])
    positions_list = []
    for record in table_3:
        positions_list.append(record[0])
    data = ui.user_input("Please give me the position's data",
                         ["Accepted: "])  # user input
    while True:
        temp_student_id = ui.user_input("", ["Student ID: "])
        if temp_student_id[0] in students_list:
            break
        ui.print_message("Wrong Student ID")
    while True:
        temp_position_id = ui.user_input("", ["Postition ID: "])
        if temp_position_id[0] in positions_list:
            break
        ui.print_message("Wrong Position_ID")
    data.append(temp_student_id[0])
    data.append(temp_position_id[0])
    id = misc.generate_random(table)  # generate id
    new_table = misc.append_table(table,
                                  misc.build_record(id,
                                                    data))  # making new table
    file_handling.export_data(new_table, filename, "w")  # saving the new table
Пример #2
0
def create_student(filename):
    table = file_handling.import_data(filename)  #import table
    data = ui.user_input("Please give me the student's data",
                         ["Name: ", "Age: ", "Active?: "])  # user input
    id = misc.generate_random(table)  # generate id
    new_table = misc.append_table(table,
                                  misc.build_record(id,
                                                    data))  # making new table
    file_handling.export_data(new_table, filename, "w")  # saving the new table
Пример #3
0
def update_student(filename):
    table = file_handling.import_data(filename)  #import table
    id = ui.user_input("Please give me the student's ID",
                       ["ID: "])  # user input, ID
    data = ui.user_input(
        "Please give me the student's data",
        ["Name: ", "Age: ", "Active?: "])  # user input, rest info
    new_table = misc.update_table(table, id[0], misc.build_record(
        id[0], data))  # updating the table
    file_handling.export_data(new_table, filename, "w")  # saving the new table
Пример #4
0
def create_position(filename, filename_2):
    table = file_handling.import_data(filename)  #import position table
    table_2 = file_handling.import_data(filename_2)  #import company table
    comp_list = []
    for record in table_2:
        comp_list.append(record[0])
    data = ui.user_input("Please give me the position's data",
                         ["Description: ", "Number of seats: "])  # user input
    while True:
        temp_company_id = ui.user_input("", ["Company ID: "])
        if temp_company_id[0] in comp_list:
            break
        ui.print_message("Wrong ID")
    data.append(temp_company_id[0])
    id = misc.generate_random(table)  # generate id
    new_table = misc.append_table(table,
                                  misc.build_record(id,
                                                    data))  # making new table
    file_handling.export_data(new_table, filename, "w")  # saving the new table
Пример #5
0
def update_company(filename):
    table = file_handling.import_data(filename) #import table
    id = ui.user_input("Please give me the ID of the company", ["ID: "]) # user input, ID
    data = ui.user_input("Please give me the datas of the company", ["Name: "]) # user input, rest info
    new_table = misc.update_table(table, id[0], misc.build_record(id[0], data)) # updating the table
    file_handling.export_data(new_table, filename, "w") # saving the new table