示例#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 delete_company(filename, pos_table):
    table = file_handling.import_data(filename) #import table
    pos_table = file_handling.import_data(pos_file) # import positions table
    id = ui.user_input("Please give me the ID of the company", ["ID: "]) # user input, ID
    for index in range(len(table)): # deleting an element from the table by index
        if table[index][0] == id[0]:
            del table[index]
            break
    file_handling.export_data(table, filename, "w")
示例#4
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
示例#5
0
def delete_application(filename):
    table = file_handling.import_data(filename)  #import table
    id = ui.user_input("Please give me the application's ID",
                       ["ID: "])  # user input, ID
    for index in range(
            len(table)):  # deleting an element from the table by index
        if table[index][0] != id[0]:
            del table[index]
            break
    file_handling.export_data(table, filename, "w")
示例#6
0
def state_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",
                         ["Active?: "])  # user input, Active?
    new_table = []
    for record in table:
        if record[0] != id[0]:
            new_table.append(record)
        else:
            record[3] = data[0]
            new_table.append(record)
    file_handling.export_data(new_table, filename, "w")  # saving the new table
示例#7
0
def update_application(filename):
    table = file_handling.import_data(filename)  #import table
    id = ui.user_input("Please give me the application's ID",
                       ["ID: "])  # user input, ID
    data = ui.user_input("Please give me the application's data",
                         ["Accepted: "])  # user input, Active?
    new_table = []
    for record in table:
        if record[0] != id[0]:
            new_table.append(record)
        else:
            record[1] = data[0]
            new_table.append(record)
    file_handling.export_data(new_table, filename, "w")  # saving the new table
示例#8
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
示例#9
0
def delete_student(st_file, app_file):
    st_table = file_handling.import_data(st_file)  #import table
    app_table = file_handling.import_data(app_file)  #import table
    app_list = []
    for record in app_table:
        app_list.append(record[2])
    while True:
        id = ui.user_input("Please give me the student's ID",
                           ["ID: "])  # user input, ID
        if id[0] in app_list:
            ui.print_message(
                "This student has an application, You can't delete it!")
        else:
            break
    for index in range(
            len(st_table)):  # deleting an element from the table by index
        if st_table[index][0] == id[0]:
            del st_table[index]
            break
    file_handling.export_data(st_table, st_file, "w")
示例#10
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