# 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": lstTable.append(Eio.input_employee_data()) print(Eio.print_menu_items()) choice = Eio.input_menu_options() if choice == "3": Fp.save_data_to_file("EmployeeData.txt", lstTable) print("File Saved!") choice = Eio.input_menu_options()
# 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 lstEmployeeTable = [] lstFileData = [] # Main Body of Script ---------------------------------------------------- # lstFileData = Fp.read_data_from_file("EmployeeData.txt") for row in lstFileData: lstEmployeeTable.append(Emp(row[0], row[1], row[2].strip())) while True: Eio.print_menu_items() strChoice = Eio.input_menu_options() if strChoice.strip() == '1': Eio.print_current_list_items(lstEmployeeTable) continue elif strChoice.strip() == '2': lstEmployeeTable.append(Eio.input_employee_data()) continue elif strChoice.strip() == '3': Fp.save_data_to_file("EmployeeData.txt", lstEmployeeTable) continue elif strChoice.strip() == '4': break
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!') elif userChoice.strip() == '3': # Save employee data to File Fp.save_data_to_file(File, lstEmpObj)
# ---------------------------------------------------------- # # Title: TestHarness.py # Description: A main module for testing # ChangeLog (Who,When,What): # RRoot,1.1.2030,Created started 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") # 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()
# ------------------------------------------------------------------------ # # Title: Assignment 09 # Description: Working with Modules # 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)
# ---------------------------------------------------------- # # Title: Listing 12 # Description: A main module for testing # ChangeLog (Who,When,What): # RRoot,1.1.2030,Created started 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") # Test data module objP1 = Emp(1, "Bob", "Smith") objP2 = Emp(2, "Sue", "Jones") objP3 = Emp(3, "Alexander", 'Bryant') lstTable = [objP1, objP2, objP3] # 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
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 lst_emp_table.append(Eio.input_employee_data()) print("Employee Data Added.")
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()) continue elif strChoice.strip() == '3':
raise Exception( "Chancho, I need borrow some sweats [and not try to import this module!]" ) # Main Body of Script ---------------------------------------------------- # # TODO: Add Data Code to the Main body # Define variables lstFileData = None lstEmployees = [] # Empty list of employee [luchador] objects strOption = "" objEmp = None # Load data from file into a list of employee objects when script starts lstFileData = FP.read_data_from_file("EmployeeData.txt") for line in lstFileData: lstEmployees.append(Emp(line[0], line[1], line[2].strip())) # Main loop while True: # Show user a menu of options Eio.print_menu_items() # Get user's menu option choice strOption = Eio.input_menu_options() if strOption == "1": # Show user current data in the list of employee objects Eio.print_current_list_items(lstEmployees) continue elif strOption == "2": # Let user add data to the list of employee objects objEmp = Eio.input_employee_data()
# RRoot,1.1.2030,Created started script # RRoot,1.1.2030,Added pseudo-code to start assignment 9 # <Your Name>,<Today's Date>,Modified code to complete assignment 9 # ------------------------------------------------------------------------ # # if __name__ == "__main__": from DataClasses import Employee as Emp import ProcessingClasses as P 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 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)) # Show user a menu of options # Get user's menu option choice while True: Eio.print_menu_options() strChoice = Eio.input_menu_options() # Show user current data in the list of employee objects if strChoice == "1": Eio.print_current_list_employees(list_of_objects) Eio.input_press_to_continue()
else: raise Exception("This file was not created to be imported") # Test data module ----- try: objP1 = D.Person("Bob", "Smith") objP2 = D.Person("Sue", "Jones") lstTable = [objP1, objP2] for row in lstTable: print(row.to_string(), type(row)) except Exception as e: raise print(e) # Test employee class ----- try: objP1 = Emp(1, "Bob", "Smith") except Exception as e: print(e) except Exception: print('Sorry Error') objP2 = Emp(2, "Sue", "Jones") lstTable = [objP1, objP2] for row in lstTable: print(row.to_string(), type(row)) # Test processing module ----- # P.FileProcessor.save_data_to_file("PersonData.txt", lstTable) # lstFileData = P.FileProcessor.read_data_from_file("PersonData.txt") # for row in lstFileData: # p = D.Person(row[0], row[1]) # print(p.to_string().strip(), type(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 # For Person data objP1 = D.Person("Bob", "Smith") objP2 = D.Person("Sue", "Jones") lstTable = [objP1, objP2] for row in lstTable: print(row.to_string(), type(row)) # For employee data 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 # saving data to PersonData P.FileProcessor.save_data_to_file("PersonData.txt", lstTable) lstFileData = P.FileProcessor.read_data_from_file("PersonData.txt") for row in lstFileData: p = D.Person(row[0], row[1]) print(p.to_string().strip(), type(p)) # Saving data to EmployeeData
# 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 try: # Load data from file into a list of employee objects when script starts list_table = FP.FileProcessor.read_data_from_file(file_name) print("Welcome to Assignment 09.") print("Please use this program to add new Employee into file.") list_of_objects.clear() for line in list_table: list_of_objects.append(Emp(line[0], line[1], line[2].strip())) # While loop to display Menu with options while True: # Show user a menu of options IO.show_menu() # Get user's menu option choice strChoice = IO.input_menu_choice() if strChoice.strip() == '1': # Show user current data in the list of employee objects IO.show_current_employees(list_of_objects) continue elif strChoice.strip() == '2': # Let user add new employee try: emp = IO.input_new_employee() list_of_objects.append(emp)