コード例 #1
0
    raise Exception("This file was not created to be imported")

# Main Body of Script  ---------------------------------------------------- #
# TODO: Add Data Code to the Main body
# Load data from file into a list of employee objects when script starts
lstFileData = []
lstEmployeeTable = []
fileName = "EmployeeData.txt"
lstFileData = Fp.read_data_from_file(fileName)
for row in lstFileData:
    lstEmployeeTable.append(Emp(row[0], row[1], row[2].strip()))

while True:

    # Show user a menu of options
    Eio.print_menu_items()

    # '''
    #         Menu of Options
    #         1) Show current employee data
    #         2) Add new employee data.
    #         3) Save employee data to File
    #         4) Exit program
    #         '''
    # Get user's menu option choice
    choice = Eio.input_menu_options()

    # Show user current data in the list of employee objects
    if choice == '1':
        Eio.print_current_list_items(lstEmployeeTable)
        continue
コード例 #2
0
# Data -------------------------------------------------------------------- #
strFileName = "EmployeeData.txt"
lstFileData = []  # List of employees
lstOfEmployees = []  # Table of employee objects
# Data -------------------------------------------------------------------- #

# Main Body of Script ----------------------------------------------------- #
try:
    lstFileData = Fp.read_data_from_file(strFileName)  # read file data
    for row in lstFileData:  # put data in consumable format
        lstOfEmployees.append(Emp(row[0], row[1], row[2].strip()))

    while True:
        # Show user a menu of options
        Eio.print_menu_items()
        # Get user's menu option choice
        strChoice = Eio.input_menu_options()
        if strChoice.strip() == '1':
            # Print Employees listed in the file (if any)
            Eio.print_current_list_items(lstOfEmployees)
            continue
        elif strChoice.strip() == '2':
            # Let user add data to the list of employee objects
            lstOfEmployees.append(Eio.input_employee_data())
            continue
        elif strChoice.strip() == '3':
            # Let user save current data to file
            Fp.save_data_to_file(strFileName, lstOfEmployees)
            continue
        elif strChoice.strip() == '4':
コード例 #3
0
    from DataClasses import Employee as EMP
    from ProcessingClasses import FileProcessor as FP
    from IOClasses import EmployeeIO as IO
else:
    raise Exception('This file was not imported')
# Main Body of Script  ---------------------------------------------------- #
# TODO: Add Data Code to the Main body
# Load data from file into a list of employee objects when script starts
lstFile = FP.read_data_from_file('EmployeeData.txt')
lstTable = []
for line in lstFile:
    lstTable.append(EMP(line[0].strip(), line[1].strip(), line[2].strip()))
# Show user a menu of options
while (True):
    try:
        IO.print_menu_items()
        # Get user's menu option choice
        option = IO.input_menu_options()
        # Show user current data in the list of employee objects
        if option == '1':
            IO.print_current_list_items(lstTable)
    # Let user add data to the list of employee objects
        elif option == '2':
            lstTable.append(IO.input_employee_data())
    # let user save current data to file
        elif option == '3':
            FP.save_data_to_file('EmployeeData.txt', lstTable)
    # Let user exit program
        elif option == '4':
            print('Thanks, goodbye')
            break
コード例 #4
0
# Main Body of Script  ---------------------------------------------------- #
# Load data from file into a list of employee objects when script starts
try:
    lstFileData = P.FileProcessor.read_data_from_file("EmployeeData.txt") #find text file by this name
    lstTable = [] #create an empty table to read out text file data
    lstTable.clear() #make sure list is cleared
    for line in lstFileData:
        lstTable.append(Emp(line[0], line[1], line[2].strip())) #reformatting data
    print("Data read in from text file: ")
    for row in lstTable:
        print("\t" + row.to_string(), type(row))


# Show user a menu of options
    while(True):
        Eio.print_menu_items()
    # Get user's menu option choice
        strChoice = Eio.input_menu_options()
        # Show user current data in the list of employee objects
        if strChoice == "1":
            Eio.print_current_list_items(lstTable)
        # Let user add data to the list of employee objects
        elif strChoice == "2":
            newEmp = Eio.input_employee_data()
            lstTable.append(newEmp)
    # let user save current data to file
        elif strChoice == "3":
            P.FileProcessor.save_data_to_file("EmployeeData.txt",lstTable)
            print("Data Saved!")
    # Let user exit program
        elif strChoice == "4":
コード例 #5
0
# Main Body of Script-----------------------------------------#
# Data #

strFileName = "EmployeeData.txt"
lstEmployeeTable = []  # A list/table of Employee objects
lstFileData = []  # A list/table of string objects in a list

# TODO: Add Data Code to the Main body (DONE)
#  Load data from file ionto a list of employee objects when sripts starts
lstFileData = Fp.read_data_from_file("EmployeeData.txt")
for row in lstFileData:
    lstEmployeeTable.append(Emp(row[0], row[1], row[2].strip()))

# Show user a menu of options
while True:
    Eio.print_menu_items()
    strOption = Eio.input_menu_options()  # Get users menu option choice
    if strOption == "1":
        # Show user current data in the list of employee objects
        Eio.print_current_list_items(lstEmployeeTable)
        continue
    elif strOption == "2":
        lstEmployeeTable.append(Eio.input_employee_data(
        ))  # Lets user add data to the list of employee objects
        continue
    elif strOption == "3":
        Fp.save_data_to_file(
            "EmployeeData.txt",
            lstEmployeeTable)  #Lets user save current data to file
        continue
    elif strOption == "4":  #Exit Program
コード例 #6
0
else:
    raise Exception("This file was not created to be imported")

# Main Body of Script  ---------------------------------------------------- #

# Load data from file into a list of employee objects when script starts
text_file = "EmployeeData.txt"
lstFileData = Fp.read_data_from_file(text_file)
lstTable = []
for line in lstFileData:
    lstTable.append(Emp(line[0], line[1], line[2].strip()))

while True:
    try:
        # Show user a menu of options
        Eio.print_menu_items()

        # Get user's menu option choice
        menu_choice = int(Eio.input_menu_options())

        # Show user current data in the list of employee objects
        if menu_choice == 1:
            Eio.print_current_list_items(lstTable)

        # Let user add data to the list of employee objects
        elif menu_choice == 2:
            new_emp = Eio.input_employee_data()
            lstTable.append(new_emp)

        # let user save current data to file
        elif menu_choice == 3:
コード例 #7
0
# Main Body of Script  ---------------------------------------------------- #
# Load data from file into a list of employee objects when script starts
objP1 = Emp(1, "Bob", "Smith")
objP2 = Emp(2, "Sue", "Jones")
lstTable = [objP1, objP2]

Fp.save_data_to_file("EmployeeData.txt", lstTable)
lstFileData = Fp.read_data_from_file("EmployeeData.txt")
lstTable.clear()
for line in lstFileData:
    lstTable.append(Emp(line[0], line[1], line[2].strip()))

# Show user a menu of options
while True:
    Eio.print_menu_items()
    menu_choice = Eio.input_menu_options()  # Get user's menu option choice
    print(menu_choice)

    if menu_choice.strip() == '1':  # Show user current data in the list of employee objects
        Eio.print_current_list_items(lstTable)
        continue

    if menu_choice.strip() == '2':  # Let user add data to the list of employee objects
        lstTable.append(Eio.input_employee_data())
        continue

    if menu_choice.strip() == '3':  # let user save current data to file
        Fp.save_data_to_file('EmployeeData.txt', lstTable)
        print('Data Saved!')
        continue
コード例 #8
0
# Get user's menu option choice
# Show user current data in the list of employee objects
# Let user add data to the list of employee objects
# let user save current data to file
# Let user exit program

# Main Body of Script  ---------------------------------------------------- #

# Read in current file and build a list of objects
lstFileData = Fp.read_data_from_file(strFileName)
lstOfEmployeeObjects.clear()
for line in lstFileData:
    lstOfEmployeeObjects.append(Emp(line[0], line[1], line[2].strip()))

while (True):
    eIO.print_menu_items()  # show user the menu
    strChoice = eIO.input_menu_options()

    # Process user's menu choice
    if strChoice.strip() == '1':  # Show Current list of products
        eIO.print_current_list_items(lstOfEmployeeObjects)
        continue  # to show the menu

    elif strChoice == '2':  # Add new employee data
        try:
            lstOfEmployeeObjects.append(eIO.input_employee_data())
        except Exception as e:
            raise print(e)
        continue  # to show the menu

    elif strChoice == '3':  # Save Data to File
コード例 #9
0
    import ProcessingClasses as P  # processing classes
    from IOClasses import EmployeeIO as IO # Input/Output classes
else:
    raise Exception("This file was not created to be imported")

# Test data module
objP1 = Emp(1, "Bob", "Smith")
objP2 = Emp(2, "Lue", "Jones")
lstTable = [objP1, objP2]
for row in lstTable:
    print(row.to_string(), type(row))

# Test processing module
P.FileProcessor.save_data_to_file("EmployeeData.txt", lstTable)
lstFileData = P.FileProcessor.read_data_from_file("EmployeeData.txt")
lstTable.clear()
for line in lstFileData:
    lstTable.append(Emp(line[0], line[1], line[2].strip()))
# for row in lstTable:
#     print(row.to_string(), type(row))

# Test IO module
IO.show_menu()
print("_______________")
IO.show_current_employees(lstTable)

print(IO.input_new_employee())
print(IO.input_menu_choice())


コード例 #10
0
# Declare variables
strFileName = 'EmployeeData.txt'
lstOfEmployeeRows = []

# Main Body of Script  ---------------------------------------------------- #
# Added code to main body to complete assignment 9

# Load data from file into a list of employee objects when script starts
lstFileData = FP.read_data_from_file(strFileName)  # load data from file
for line in lstFileData:
    lstOfEmployeeRows.append(E(line[0], line[1],
                               line[2].strip()))  # add data to list

# Show user a menu of options
while True:
    eIO.print_menu_items()

    # Get user's menu option choice
    strChoice = eIO.input_menu_options()

    # Show user current data in the list of employee objects
    if strChoice.strip() == '1':
        eIO.print_current_list_items(lstOfEmployeeRows)

    # Let user add data to the list of employee objects
    elif strChoice.strip() == '2':
        objEmployee = eIO.input_employee_data()
        lstOfEmployeeRows.append(objEmployee)  # add object to list

    # Let user save current data to file
    elif strChoice.strip() == '3':
コード例 #11
0
if __name__ == "__main__":
    from ProcessingClasses import FileProcessor as Fp
    from IOClasses import EmployeeIO as Eio
else:
    raise Exception("This file was not created to be imported")

strFileName = "EmployeeData.txt"
lstEmployeeData = []

# Main Body of Script  ---------------------------------------------------- #
# Load data from file into a list of employee objects when script starts
lstEmployeeData = Fp.read_data_from_file(strFileName)

while True:
    # Show user a menu of options
    Eio.print_menu_items()
    # Get user's menu option choice
    strChoice = Eio.input_menu_options()  # get menu option

    # Show user current data in the list of employee objects
    if strChoice == "1":
        Eio.print_current_list_items(lstEmployeeData)
    # Let user add data to the list of employee objects
    elif strChoice == "2":
        objEmp = Eio.input_employee_data()  # create new employee object
        lstEmployeeData.append(
            objEmp)  # append to existing list of employee objects
    # let user save current data to file
    elif strChoice == "3":
        Fp.save_data_to_file(strFileName, lstEmployeeData)
        print("Data Saved")
コード例 #12
0
ファイル: Main.py プロジェクト: chownh/Assignment09
# Get user's menu option choice
# Show user current data in the list of employee objects (Done)
# Let user add data to the list of employee objects (Done)
# let user save current data to file (Done)
# Let user exit program (Done)

EmployeeTable = []  # Initializing a list table for objects
lstFileData = []  # Initializing a list table for objects

lstFileData = Fp.read_data_from_file("EmployeeData.txt")
for row in lstFileData:
    EmployeeTable.append(Emp(row[0], row[1], row[2].strip()))

# Show user a menu of options
while True:
    Eio.print_menu_items()
    strOption = Eio.input_menu_options()
    if strOption == "1":  # Show user current data in the list of employee objects
        Eio.print_current_list_items(EmployeeTable)
        continue
    elif strOption == "2":  # Let user add data to the list of employee objects
        EmployeeTable.append(Eio.input_employee_data())
        continue
    elif strOption == "3":  # let user save current data to file
        if ("y" == str(
                input("Save this data to file? (Y / N) - ")).strip().lower()
            ):  # Double-check with user
            Fp.save_data_to_file("EmployeeData.txt", EmployeeTable)
            input(
                "Data saved to file! Press the [Enter] key to return to menu.")
        else:  # Let the user know the data was not saved
コード例 #13
0
for row in lstTable:
    print(row.to_string(), type(row))

# Test writing to PersonData.txt
FP.save_data_to_file("EmployeeData.txt", lstTable)
lstFileData = FP.read_data_from_file("EmployeeData.txt")
lstTable.clear()
for line in lstFileData:
    lstTable.append(EMP(line[0], line[1], line[2].strip()))
for row in lstTable:
    print(row.to_string())

# Test IO class
cont = True
while cont == True:
    EIO.print_menu_items()
    strChoice = EIO.input_menu_options()
    if strChoice == "1":
        for row in lstTable:
            print(row.to_string())
    elif strChoice == "2":
        EmpInput = []
        EmpInput = EIO.input_employee_data()
        lstTable.append(EmpInput)
        for row in lstTable:
            print(row.to_string())
    elif strChoice == "3":
        FP.save_data_to_file("EmployeeData.txt",lstTable)
        print("Data was saved to file")
    elif strChoice == "4":
        cont = False
コード例 #14
0
    raise Exception("This file was not created to be imported")

# Data ----------------------------------------------------- #
lstOfEmployeeObjects = []  # A list of object rows
strFileName = "EmployeeData.txt"  # The target file for reading/writing
strMenuChoice = ""  # Captures user input for menu choice
objFile = None  # Object for opening/closing target file
objEmployee = None  # Object collecting user input data, 3 attributes

# Main Body of Script -------------------------------------- #
lstOfEmployeeObjects = Fp.read_data_from_file(strFileName)
print(lstOfEmployeeObjects)

# Show user a menu of options
while True:
    Eio.print_menu_items()

    # Get user's menu option choice
    strChoice = Eio.input_menu_options()

    # Show current employee data to user
    if strChoice.strip() == "1":
        Eio.print_current_list_items(lstOfEmployeeObjects)
        continue

    # Let user add new employee data
    if strChoice.strip() == "2":
        while True:  # While loop prevents being kicked back to main menu during error
            try:
                objEmployee = Eio.input_employee_data()
                lstOfEmployeeObjects.append(objEmployee)
コード例 #15
0
else:
    raise Exception("This file was not created to be imported")
# Data
lstTable = []

# Main Body of Script  ---------------------------------------------------- #

# Load data from file into a list of employee objects when script starts
lstFileData = Fp.read_data_from_file("EmployeeData.txt")
lstTable.clear()
for line in lstFileData:
    lstTable.append(Emp(line[0], line[1], line[2].strip()))

while True:
    # Show user a menu of options
    Eio.print_menu_items()

    # Get user's menu option choice
    choice = Eio.input_menu_options()

    if choice == "1":  # Show user current data in the list of employee objects
        Eio.print_current_list_items(lstTable)
    elif choice == "2":  # Let user add data to the list of employee objects
        EmpEntered = Eio.input_employee_data()
        lstTable.append(EmpEntered)
    elif choice == "3":  # let user save current data to file
        Fp.save_data_to_file("EmployeeData2.txt", lstTable)
    elif choice == "4":  # Let user exit program
        break
    else:
        raise Exception("Invalid input. Enter 1-4 only!")
コード例 #16
0
    from IOClasses import EmployeeIO as Eio
else:
    raise Exception("This file is not meant to ran by itself")

# Main Body of Script  ---------------------------------------------------- #
# TODO: Add Data Code to the Main body
# Load data from file into a list of employee objects when script starts
lstTable = []
lstFileData = Fp.read_data_from_file("EmployeeData.txt")
lstTable.clear()
for line in lstFileData:
    lstTable.append(Emp(line[0], line[1], line[2].strip()))

# Show user a menu of options
while (True):
    Eio.print_menu_items()  # Shows menu
    strChoice = Eio.input_menu_options()  # Get user's menu option choice

    if strChoice.strip(
    ) == '1':  # Show user current data in the list of employee objects
        for row in lstTable:
            line = row.to_string()
            print(row.to_string())
        continue  # to show the menu

    elif strChoice == '2':  # Let user add data to the list of employee objects
        addEmp = Eio.input_employee_data()
        print(addEmp.first_name + " has been added")
        lstTable.append(addEmp)
        continue  # to show the menu
コード例 #17
0
else:
    raise Exception("This file was not created to be imported")

# Main Body of Script  ---------------------------------------------------- #
# TODO: Add Data Code to the Main body
try:
    file_name = "EmployeeData.txt"
    list_of_employees = []
    input = None
    # Load data from file into a list of employee objects when script starts
    lstFileData = Fp.read_data_from_file(file_name)
    for line in lstFileData:
        list_of_employees.append(E(line[0], line[1], line[2].strip()))
    # Show user a menu of options
    while (True):
        Eio.print_menu_items()
        # Get user's menu option choice
        input = Eio.input_menu_options()
        # Show user current data in the list of employee objects
        if input == "1":
            Eio.print_current_list_items(list_of_employees)
        # Let user add data to the list of employee objects
        elif input == "2":
            new_data = Eio.input_employee_data()
            list_of_employees.append(new_data)
            print("New employee data successfully added!")
        # let user save current data to file
        elif input == "3":
            print(Fp.save_data_to_file(file_name, list_of_employees))
        # Let user exit program
        elif input == "4":
コード例 #18
0
    from DataClasses import Employee as Emp
    from ProcessingClasses import FileProcessor as Fp
    from IOClasses import EmployeeIO as Eio
else:
    raise Exception("This file was not created to be imported")

# Main Body of Script  ---------------------------------------------------- #
lstEmpTable = []
lstFileData = []

lstFileData = Fp.read_data_from_file("EmployeeData.txt")
for row in lstFileData:
    lstEmpTable.append(Emp(row[0], row[1], row[2].strip()))

while True:  # Show user a menu of options
    Eio.print_menu_items()
    strChoice = Eio.input_menu_options()  # Get user's menu option choice
    if strChoice == '1':
        Eio.print_current_list_items(
            lstEmpTable
        )  # Show user current data in the list of employee objects
    if strChoice == '2':
        lstEmpTable.append(Eio.input_employee_data(
        ))  # Let user add data to the list of employee objects
    if strChoice == '3':
        Fp.save_data_to_file('EmployeeData.txt',
                             lstEmpTable)  # let user save current data to file
    if strChoice == '4':
        break  # Let user exit program

# Main Body of Script  ---------------------------------------------------- #
コード例 #19
0
    raise Exception("This file was not created to be imported.")

# test data processing module - create person
per1 = PersonConst("Test", "Person")
testPeople = [per1]
for row in testPeople:
    print(row.to_string(), type(row))

# test data processing module - create employee
emp1 = EmployeeConst(1, "Beau", "Barth")
emp2 = EmployeeConst(2, "Dana", "Barth")
testData = [emp1, emp2]
for row in testData:
    print(row.to_string(), type(row))

#  test file processing - save data
FPClass.save_data_to_file("EmployeeData.txt", testData)

#  test file processing - read data
readfile = FPClass.read_data_from_file("EmployeeData.txt")  # read from file
testData.clear()  # clear testData before append, print
for row in readfile:
    testData.append(EmployeeConst(
        row[0], row[1], row[2].strip()))  # converts row to employee object
for row in testData:
    print(row.to_string(), type(row))

#  test employee IO processing - get new employee
testEmployee = EmpIO.input_employee_data()
print(testEmployee)
コード例 #20
0

# Main Body of Script  ---------------------------------------------------- #

# exceptions
class InvalidChoice(Exception):
    def __str__(self):
        return "Please choose from menu: option 1, 2, 3, or 4."


# initialize variables
strFileName = "EmployeeData.txt"

# Load data from file into a list of employee objects when script starts
lstEmployees = FileProcessor.read_data_from_file(strFileName)
EmployeeIO.print_current_list_items(lstEmployees)
# Show user a menu of options
while True:
    try:
        EmployeeIO.print_menu_items()
        intUserChoice = int(EmployeeIO.input_menu_options())
        if intUserChoice == 1:
            EmployeeIO.print_current_list_items(lstEmployees)
        elif intUserChoice == 2:
            newEmployee = EmployeeIO.input_employee_data()
            lstEmployees.append(newEmployee)
        elif intUserChoice == 3:
            FileProcessor.save_data_to_file(strFileName, lstEmployees)
        elif intUserChoice == 4:
            break
        else:
コード例 #21
0
lstEmpData = P.FileProcessor.read_data_from_file(file_name)
lstTable.clear()

# list loop, creats emp object, populates it with employee properties from file
for list in lstEmpData:
    emp = Emp(list[0], list[1], list[2].strip())
    lstTable.append(emp)

# ------------------------------------------------------------------------ #

# Main Body of Script  ---------------------------------------------------- #

# Loop for main
while True:
    # Show user a menu of options
    Eio.print_menu_items()

    # Get user's menu option choice
    user_input = Eio.input_menu_options()

    # Show user current data in the list of employee objects
    if user_input == '1':
        Eio.print_current_list_items(lstTable)
    # Let user add data to the list of employee objects
    elif user_input== '2':
        emp = Eio.input_employee_data()
        lstTable.append(emp)
    # let user save current data to file
    elif user_input == '3':
        P.FileProcessor.save_data_to_file(file_name, lstTable)
    # Let user exit program
コード例 #22
0
# Test Module
# objPI = D.Person("Andrew", "Jackson")
# objP2 = D.Person("James", "Buchanan")
# lstTable = [objPI, objP2]
# for row in lstTable:
#     print(row.to_string(), type(row))

# Test Data Module
objPI = Emp(1, "Andrew", "Jackson")
objP2 = Emp(2, "James", "Buchanan")
list_of_objects = [objPI, objP2]
for row in list_of_objects:
    print(row.to_string(), type(row))

# Test Processing Module
P.FileProcessor.save_data_to_file("EmployeeData.txt", list_of_objects)
fileData = P.FileProcessor.read_data_from_file("EmployeeData.txt")
list_of_objects.clear()
for line in fileData:
    list_of_objects.append(Emp(line[0], line[1], line[2].strip()))
for row in list_of_objects:
    print(row.to_string(), type(row))

# Test IO Classes
Eio.print_menu_options()
Eio.print_current_list_employees(list_of_objects)
print(Eio.input_menu_options())
print(Eio.input_employee_data())


コード例 #23
0
lstLstTable = []  # list of lists
lstObjTable = []  # list of objects
fn = "EmployeeData.txt"  # file to read current employee data
strChoice = ""  # string to store user's choice

# Main Body of Script  ---------------------------------------------------- #

# Load data from file into a list of employee objects when script starts
lstTable = Fp.read_data_from_file(fn)  # create a list of lists
for i in lstTable:  # iterate through the list of lists
    lstObjTable.append(Emp(
        i[0], i[1], i[2].strip()))  # add employee object to list of objects

while True:
    # Show user a menu of options
    Eio.print_menu_items(
    )  # use EmployeeIO class of IOClasses Module to print menu

    # Get user's menu option choice, and check for errors
    try:  # check that code will run
        strChoice = Eio.input_menu_options()  # store user's selection
    except Exception as e:  # exception handled
        print(e)  # print error message

    # Show user current data in the list of employee objects
    if strChoice == '1':  # checks if user entered 1
        Eio.print_current_list_items(
            lstObjTable)  # print current list of employees
        input("Press [Enter] key to return to the menu. "
              )  # print message to continue

    # Let user add data to the list of employee objects
コード例 #24
0
# Test Person class from DataClasses module
objP1 = P("Nacho", "Libre")
objP2 = P("Steven", "Esqueleto")
objP3 = P("Sister", "Encarnación")
lstTable = [objP1, objP2, objP3]
for row in lstTable:
    print(row.to_string(), type(row))  # Check person objects

# Test Employee class from DataClass module adding employee number (use existing data, not re-enter)
objE1 = Emp(1, objP1.first_name, objP1.last_name)
objE2 = Emp(2, objP2.first_name, objP2.last_name)
objE3 = Emp(3, objP3.first_name, objP3.last_name)
lstEmployees = [objE1, objE2, objE3]
for row in lstEmployees:
    print(row.to_string(), type(row))  # Check employee objects

#  Test FileProcessor class from ProcessingClasses module
FP.save_data_to_file("EmployeeData.txt", lstEmployees)  # Save data
lstFileData = FP.read_data_from_file("EmployeeData.txt")  # Read data back in
lstEmployees.clear()  # Clear list
for line in lstFileData:  # Repopulate list
    lstEmployees.append(Emp(line[0], line[1], line[2].strip()))
for row in lstEmployees:  # Print list
    print(row.to_string(), type(row))

# Test IO classes
Eio.print_menu_items()  # check menu print
Eio.print_current_list_items(lstEmployees)  #
print(Eio.input_employee_data())
print(Eio.input_menu_options())
コード例 #25
0
    print(row.to_string(), type(row))

# Test IO classes
# TODO: create and test IO module

Fp.save_data_to_file("EmployeeData.txt", lstTable)
lstFileData = Fp.read_data_from_file("EmployeeData.txt") # Load data from file into a list of employee objects when script starts
lstTable.clear()
for line in lstFileData:
    lstTable.append(Emp(line[0], line[1], line[2].strip()))
for row in lstTable:
    print(row.to_string(), type(row))

while (True):
    #Eio.print_current_list_items(lstTable) # Show current data in the list/table
    Eio.print_menu_items() # Show user a menu of options
    strChoice = Eio.input_menu_options()  # Get user's menu option choice

    if strChoice == '1':  # Add a new Task
        Eio.print_current_list_items(lstTable)# Show user current data in the list of employee objects
        continue # to show the menu

    elif strChoice == '2': #add new employee data
        print(Eio.input_employee_data()) # print new employee
        continue # to show the menu

    elif strChoice == '3':  # # let user save current data to file
        #p.save_data_to_file("PersonData.txt", lstTable)
        Fp.save_data_to_file("EmployeeData.txt", lstTable)
        lstFileData = Fp.read_data_from_file("EmployeeData.txt")
        lstTable.clear()
コード例 #26
0
# Show user a menu of options
# Get user's menu option choice
# Show user current data in the list of employee objects
# Let user add data to the list of employee objects
# let user save current data to file
# Let user exit program

# Main Body of Script  ---------------------------------------------------- #
if __name__ == "__main__":
    from DataClasses import Employee as Emp
    from ProcessingClasses import FileProcessor as Fp
    from IOClasses import EmployeeIO as Eio
else:
    raise Exception("This file was not created to be imported")

print(Eio.print_menu_items())

choice = Eio.input_menu_options()
lstFileData = Fp.read_data_from_file("EmployeeData.txt")
lstTable = []
lstTable.clear()
for line in lstFileData:
    lstTable.append(Emp(line[0], line[1], line[2].strip()))

while (True):
    if choice == "1":
        print(Eio.print_current_list_items(lstTable))
        print(Eio.print_menu_items())
        choice = Eio.input_menu_options()

    if choice == "2":