-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprojectInterface.py
More file actions
116 lines (100 loc) · 3.59 KB
/
projectInterface.py
File metadata and controls
116 lines (100 loc) · 3.59 KB
1
'''This program will eventually run all cs projects I have done in python.'''import sys, os, resys.path.append(os.getcwd()+'/src/pythonBasics/')sys.path.append(os.getcwd()+'/src/pythonBasics/bingo/')sys.path.append(os.getcwd()+'/src/advancedPython/')sys.path.append(os.getcwd()+'/src/dataProcessing/src/')sys.path.append(os.getcwd()+'/src/juliaMandelbrot/src/')#basic python stuffimport basicPasswordValidator, cardGame, TestCheckSodokuSolution, circles, coinFlipimport creditCardValidator, diceGame, drawOlympicRings, drawRectangle, estimatePiimport findPerfectNumbers, fourInARow, histogram, investmentCalculatorimport lotteryGame, palindromeChecker, payroll, python_text_toolsimport recursiveWebCrawler, rockPaperScissors, ShowCurrentTime, stopwatchimport TestCheckSodokuSolution, tkinterPractice, turtleWalk, Bingo#advanced python stuffimport EditDistanceDNA, fftAlgorithim, hemmingDistanceWiki, justFFT, justFFT2import minEditDistance, minEditDistanceDNA, nimGame, polyMult, simpleKnapsackimport workReportStats, fractalsbasicSwitcher = { 1: basicPasswordValidator, 2: cardGame, 3: TestCheckSodokuSolution, 4: circles, 5: coinFlip, 6: creditCardValidator, 7: diceGame, 8: drawOlympicRings, 9: drawRectangle, 10: estimatePi, 11: findPerfectNumbers, 12: fourInARow, 13: histogram, 14: investmentCalculator, 15: lotteryGame, 16: palindromeChecker, 17: payroll, 18: python_text_tools, 19: recursiveWebCrawler, 20: rockPaperScissors, 21: ShowCurrentTime, 22: stopwatch, 23: TestCheckSodokuSolution, 24: tkinterPractice, 25: turtleWalk, 26: Bingo, }advancedSwitcher = { 1: EditDistanceDNA, 2: fftAlgorithim, 3: hemmingDistanceWiki, 4: justFFT, 5: justFFT2, 6: minEditDistance, 7: minEditDistanceDNA, 8: nimGame, 9: polyMult, 10: simpleKnapsack, 11: workReportStats, 12: fractals, }switchers = { 1: basicSwitcher, 2: advancedSwitcher, }def chooseSwitcher(p): func = switchers.get(p, lambda: "Invalid input.") return func def chooseProgram(p, switcher): # Get the function from switcher dictionary func = switcher.get(p, lambda: "Invalid program name.") # Execute the function func.run() if __name__ == "__main__": try: while True: print("\nPress ctrl+c at anytime to exit this program.\n") print("1: Basic Python programs") print("2: Advanced Python programs") userSwitcher = int(input("Select which type of program to view by "\ "entering the corresponding number.\n")) switcher = chooseSwitcher(userSwitcher) print("\nPick a program from the list below by entering the corresponding number.\n") for k, v in switcher.items(): print("{}: {}".format(k, " ".join(re.findall('[A-Z][^A-Z]*', re.sub('([a-zA-Z])', lambda x: x.groups()[0].upper(), v.__name__, 1))))) userProgram = int(input("\nSelect program: ")) print("\n\n\n\n") try: chooseProgram(userProgram, switcher) except Exception as e: print("An exception occured running this program.") print(e) print("\n\n\n\n") except KeyboardInterrupt: sys.exit(0)