示例#1
0
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.")

# Main Body of Script  ---------------------------------------------------- #
# -- Data -- #
lst_emp_table = []
lst_file_data = []

# Load data from file into a list of employee objects when script starts

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

# Show user a menu of options

while True:
    Eio.print_menu_items()
# Get user's menu option choice
    str_choice = Eio.input_menu_options()
    if str_choice == "1":
    # Show user current data in the list of employee objects
        Eio.print_current_list_items(lst_emp_table)
        continue
    elif str_choice == "2":
    # Let user add data to the list of employee objects
示例#2
0
# let user save current data to file
# Let user exit program

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

try:
    strFileName = 'EmployeeData.txt'
    lstTable = []
    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':
            # Show user current data in the list of product objects
            lstFileData = Fp.read_data_from_file(strFileName)
            lstTable.clear()
            for line in lstFileData:
                lstTable.append(Emp(line[0], line[1], line[2].strip()))
            Eio.print_current_list_items(lstTable)
            continue
        elif strChoice.strip() == '2':
            # Let user add data to the list of product objects
            lstTable.append(Eio.input_employee_data())
            Eio.print_current_list_items(lstTable)
            continue
        elif strChoice.strip() == '3':
            # let user save current data to file and exit program
            Fp.save_data_to_file(strFileName, lstTable)
            Eio.print_current_list_items(lstTable)
            continue
示例#3
0
lstTable = [objP1, objP2]
for row in lstTable:
    print(row.to_string(), type(row))

# Test the Employee class from DataClasses
print("\nTesting the Employee class from DataClasses")
lstTable = []
objEmp1 = Emp(1, "Theresa", "Ward")
objEmp2 = Emp(2, "Michael", "Williams")
lstTable = [objEmp1, objEmp2]
for row in lstTable:
    print(row.to_string(), type(row))

# Test processing module from ProcessingClasses.
# I've decided to check read_data_to_file instead
print("\nTesting the processing module from DataClasses")
lstTable = []
Fp.read_data_from_file("EmployeeData.txt")
lstFileData = Fp.read_data_from_file("EmployeeData.txt")
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 the EmployeeIO class from IOClasses
print("\nTesting the EmployeeIO class from IOClasses")
Eio.print_menu_items()
Eio.print_current_list_items(lstTable)
print(Eio.input_employee_data())
print(Eio.input_menu_options())
示例#4
0
else:  # raise exception if this has been imported
    raise Exception("This file was not created to be imported"
                    )  # Exception raised with message

# print(locals())  # used to check local symbol table, just playing around

# Variables
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
    from IOClasses import EmployeeIO as Eio
    import Listing07 as P  # processing classes
else:
    raise Exception("This file was not created to be imported")

# Test data module
objP1 = Emp(1, "Bob", "Smith")
objP2 = Emp(2, "Sue", "Jones")
lstTable = [objP1, objP2]
for row in lstTable:
    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
示例#6
0
# ------------------------------------------------------------------------ #

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")

# 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
    #         '''
示例#7
0
# ABryant,6.14.2020,Removed try-except block after modifying the employee class
# ABryant,6.15.2020,Captured demo images in PyCharm and Command Line, tidied for Git push
# ------------------------------------------------------------------------ #

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")

# 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)
示例#8
0
# RRoot,1.1.2030,Created started script
# RRoot,1.1.2030,Added pseudo-code to start assignment 9
# KOdland,6.14.2020,Modified code to complete assignment 9
# ------------------------------------------------------------------------ #
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
    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 ------------------------------------------------------------------------------------------------ #

lstEmployeeTable = []
lstFileData = []
Txt = "EmployeeData.txt"

# TODO: Add Data Code to the Main Body (Done)

# Load data from file into a list of employee objects when script starts
lstFileData = Fp.read_data_from_file(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()

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

    elif strOption == "2":
        # Let user add data to the list of employee objects
        lstEmployeeTable.append(Eio.input_employee_data())
示例#10
0
# Description: A script to run and test the other modules to make sure the are working
# ChangeLog:
#   Austin Biehl, 09.03.2020, Import Person, Processing, Data, and IO classes
# ---------------------------------------------------------- #
# Harness script begins
#
if __name__ == "__main__":
    from DataClasses import Person as P
    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")

# Test reading PersonData.txt
lstFileData = FP.read_data_from_file("PersonData.txt")
lstTable = []
for line in lstFileData:
    lstTable.append(P(line[0], line[1].strip()))
for row in lstTable:
    print(row.to_string())

# Test writing to PersonData.txt
FP.save_data_to_file("PersonData.txt", lstTable)
lstFileData = FP.read_data_from_file("PersonData.txt")
lstTable.clear()
for line in lstFileData:
    lstTable.append(P(line[0], line[1].strip()))
for row in lstTable:
    print(row.to_string())
#
示例#11
0
# ------------------------------------------------------------------------ #

# Import modules
from DataClasses import Employee as E
from ProcessingClasses import FileProcessor as FP
from IOClasses import EmployeeIO as eIO

# 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)
示例#12
0
    import sys
    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")

# 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())
示例#13
0
# ------------------------------------------------------------------------ #
if __name__ == "__main__":
    from DataClasses import Person as Per
    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  ---------------------------------------------------- #
File = "EmployeeData.txt"
lstEmpObj = []
userChoice = ""

# Load data from file into a list of employee objects when script starts
fileData = Fp.read_data_from_file(File)
for line in fileData:
    lstEmpObj.append(Emp(line[0], line[1], line[2].strip()))

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

    if userChoice.strip() == '1':  # Show current employee data
        Eio.print_current_list_items(lstEmpObj)

    elif userChoice.strip() == '2':  # Add new employee data
        lstEmpObj.append(Eio.input_employee_data())
        print('Employee added, press 3 to save this data to file!')
示例#14
0
# ChangeLog (Who,When,What):
# RRoot,1.1.2020,Created started script
# RRoot,1.1.2020,Added pseudo-code to start assignment 9
# AAsgekar,6.15.2020,Modified code to complete assignment 9
# ------------------------------------------------------------------------ #
if __name__ == "__main__":
    from DataClasses import Employee as Emp
    from ProcessingClasses import FileProcessor as P
    from IOClasses import EmployeeIO as Eio

strFileName = "EmployeeData.txt"
currentList = ""
objP1 = Emp(1, "", "")
# Main Body of Script  ---------------------------------------------------- #
# Load data from file into a list of employee objects when script starts
currentList = P.read_data_from_file(strFileName)

choice = " "
while choice != "4":
    # 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
        if currentList != []:  # Check if there is any data in the list
            Eio.print_current_list_items(currentList)
            input("Press Enter to return to the Menu.")
        else:
            print("The list is currently empty.")
示例#15
0
from IOClasses import EmployeeIO

# Test data module - class Person
objP1 = Person("Bob", "Smith")
objP2 = Person("Sue", "Jones")
lstTable = [objP1, objP2]
for row in lstTable:
    print(row.to_string(), type(row))

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

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

# Test IO module - class EmployeeIO
EmployeeIO.print_menu_items()
EmployeeIO.print_current_list_items(lstTable)
print(EmployeeIO.input_employee_data())
print(EmployeeIO.input_menu_options())
示例#16
0
# RRoot,1.1.2030,Created started script
# ---------------------------------------------------------- #
if __name__ == "__main__":
    from DataClasses import Person as P
    from ProcessingClasses import FileProcessor as Fp
    from IOClasses import EmployeeIO as Eio
else:
    raise Exception("This file was not created to be imported")

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

# Test processing module
Fp.save_data_to_file("PersonData.txt", lstTable)
lstFileData = Fp.read_data_from_file("PersonData.txt")
for row in lstTable:
    print(row.to_string(), type(row))

# Test IO classes
# TODO: create and test IO module
Eio.input_menu_options()
print(Eio.input_menu_options())
Eio.print_current_list_items(lstTable)
print(Eio.input_employee_data())


示例#17
0
# ChangeLog (Who,When,What):
# RRoot,1.1.2030,Created started script
# RRoot,1.1.2030,Added pseudo-code to start assignment 9
# BBicksler,12.14.2020,Modified code to complete assignment 9
# ------------------------------------------------------------------------ #
# Import Modules
if __name__ == "__main__":
    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())
示例#18
0
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")

# Data
strFileName = "EmployeeData.txt"
lstTable = []

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

# Load data from file into a list of employee objects when script starts
try:
    lstFileData = Fp.read_data_from_file(strFileName) # create and return list of object rows from file
    lstTable.clear() # Clear list before loading from file
    for line in lstFileData: # Convert list of string to Employee objects
        lstTable.append(Emp(line[0], line[1], line[2].strip())) # Build Employee object on same line as appending it to list

    while True: # while loop to return to menu of options
        # 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':
            # Show user current data in the list of employee objects
            # for row in lstTable: # for testing purposes
            #     print(row.to_string(), type(row)) # for testing purposes
            Eio.print_current_list_items(lstTable)
示例#19
0
if __name__ == "__main__":
    from DataClasses import Employee as E
    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  ---------------------------------------------------- #
# 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!")
示例#20
0
strChoice = ""  # Captures the user option selection

# Main Body of Script  ---------------------------------------------------- #
#
# Load data from file into a list of employee objects when script starts
# 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  ---------------------------------------------------- #

# 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:
    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)
示例#22
0
# RRoot,1.1.2030,Added pseudo-code to start assignment 9
# Paul Mitchell,12/15/2020,Modified code to complete assignment 9
# ------------------------------------------------------------------------ #
# TODO: Import Modules
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 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
示例#23
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-----------------------------------------#
# 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
示例#24
0
# RRoot,1.1.2030,Created started script
# RRoot,1.1.2030,Added pseudo-code to start assignment 9
# ISanchez,12.8.2019,Modified code to complete assignment 9
# ------------------------------------------------------------------------ #
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")

# 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',
示例#25
0
#Change Log
#lredinger,191129,created file
#lredinger,191201, added code to complete Assignment09

# modules
if __name__ == "__main__":
    from DataClasses import Employee as Emp
    from ProcessingClasses import FileProcessor as Fp
    from IOClasses import EmployeeIO as EmpIo
else:
    raise Exception("This file was not intended for import")

# data
file_name = "EmployeeData.txt"
empList = []
fileList = Fp.read_data_from_file(file_name)

# pull data from file into list
for row in fileList:
    empList.append(Emp(row[0], row[1], row[2].strip()))

# main script using modules
while True:
    # menu handling
    EmpIo.print_menu_items()
    usrCh = EmpIo.input_menu_options()

    # show current employees
    if usrCh == "1":
        EmpIo.print_current_list_items(empList)
示例#26
0
from IOClasses import EmployeeIO


# 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
示例#27
0
# Title: Assignment 09
# Description: Assignment 09
# ChangeLog (Who,When,What):
# bbarth,12.5.2019, Created Script
# ---------------------------------------------------------- #
if __name__ == "__main__":
    from DataClasses import Employee as EmployeeClass
    from ProcessingClasses import FileProcessor as FPClass
    from IOClasses import EmployeeIO as IOClass
else:
    raise Exception("This file was not created to be imported.")

empList = []  # list of employees

# On load, read data from text file and append each row to data list in context
readfile = FPClass.read_data_from_file("EmployeeData.txt")
for row in readfile:
    empList.append(EmployeeClass(row[0], row[1], row[2].strip()))

#  Operations
while True:
    IOClass.print_menu_items()  # display menu
    choice = IOClass.input_menu_options()  # determine choice
    if choice == "1":
        IOClass.print_current_list_items(empList)  # print data list in context
        continue
    elif choice == "2":
        dataAdded = IOClass.input_employee_data(
        )  # execute input_employee_data to determine data to be added
        empList.append(dataAdded)  # add employee data to data list in context
        continue
# 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())
# RRoot,1.1.2030,Created started script
# RShip 12.16.20 used template to complete scrip.
# ---------------------------------------------------------- #
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")

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

# Test processing module
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(), type(row))

# Test IO classes
Eio.print_menu_items()
Eio.print_current_list_items(lstTable)
print(Eio.input_employee_data())
print(Eio.input_menu_options())
示例#30
0
# for row in lstTable:
#     print(row.to_string(), type(row))
# Test IO classes
# Eio.print_menu_items()
# Eio.print_current_list_items(lstTable)
# print(Eio.input_employee_data())
# print(Eio.input_menu_options())

# 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
# 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()))
#SDH NO NEED TO PRINT THIS HERE
# for row in lstTable:
#     print(row.to_string(), type(row))

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

#SDH COPY THE MENU CODE BELOW FROM ASSIGNMENT06 AND MODIFY THE NAMES

# Get user's menu option choice
while (True):
    Eio.print_menu_items()  # Shows menu