def processChoicesForFiles(folderOpts, fileOpts): if len(folderOpts.keys()) >= 1: print("\n Pick which type of file to rename: ") folderChoice = printOptions(addOption(folderOpts, "GO BACK")) while folderChoice != len(folderOpts.keys()): files = fileOpts[folderChoice] fileType = folderOpts[folderChoice] fileChoice = printOptions(addOption(files, "GO BACK")) while fileChoice != len(files.keys()): oldName = files[fileChoice] fileNameOption = printOptions( addOption(OPTIONS_NAME, "GO BACK")) while fileNameOption != len(OPTIONS_NAME.keys()): if fileNameOption == 2: newName = input( "\n\tWhat would you like to rename your {} " "file? ".format(fileType)) else: newName = fileNameGet(fileType) fileRename(oldName, newName, fileType) fileNameOption = len(OPTIONS_NAME.keys()) fileChoice = len(files.keys()) folderChoice = printOptions(folderOpts) else: print("\n\t\tNo files to rename in directory.")
def assignmentsFilter(dateString): today = dateString dates = SCHEDULE_DATA["list"] courseData = SCHEDULE_DATA["dictionary"] if scheduleCheck(today, dates): assignment = courseData[today] print("\n\tThere's assignment data for {}, in week {}".format( today, assignment["Week"])) assignmentOpts = {} assignmentMap = {} index = 1 for key in sorted(assignment.keys()): if key not in ["Date", "Week", "Class", "Day"]: print("\t\t", key + ": ", assignment[key]) if key in ["Lab", "Homework"]: assignmentMap[index] = key assignmentOpts[index] = assignment[key] index += 1 for key, value in assignmentOpts.items(): fileType = assignmentMap[key].lower() response = input( "\n Would you like to create a file for this " "'{}' assignment ('Y' = 'Yes'): ".format(fileType)) if fileType == "lab": fileType += "s" if response.upper() in ["Y", "YES"] and len(response) > 0: fileNameOption = printOptions( addOption(OPTIONS_NAME, "GO BACK")) while fileNameOption != len(OPTIONS_NAME.keys()): if fileNameOption == 2: fileName = input( "\n\tWhat would you like to name your {} " "file? ".format(fileType)) else: if fileType.lower() in ["lab", "labs"]: fileTypeName = assignment["Lab"].lower() elif fileType == "Homework": fileTypeName = assignment["Homework"].lower() else: fileTypeName = "assignment" fileName = "ch{}.{}.{}.py".format( assignment["Chapter"], fileTypeName, today) fileCreate(fileName, fileType) fileNameOption = len(OPTIONS_NAME.keys()) else: dateOpts, assignmentOpts = buildChoicesForDates( SCHEDULE_DATA['dictionary']) while today is not None: print("\n\t\tThere's no assignment data for {}".format(today)) response = input("\n Would you like to create a file for a " "different date ('Y' = 'Yes'): ") if response.upper() in ["Y", "YES"]: dateString = processChoicesForDates(dateOpts) assignmentsFilter(dateString) actionGet(addOption(OPTIONS, "QUIT"))
def actionGet(options): option = printOptions(options) while option != len(OPTIONS.keys()): print("\n\t Okay, let's " + OPTIONS[option].lower() + "...") if option == 1: response = input("\n Would you like to create a file for a " "specific date ('Y' = 'Yes'): ") if response.upper() in ["Y", "YES"]: dateOpts, assignmentOpts = buildChoicesForDates( SCHEDULE_DATA['dictionary']) dateString = processChoicesForDates(dateOpts) while dateString != len(dateOpts.keys()): assignmentsFilter(dateString) fileInt = printOptions(addOption(OPTIONS_FILE, "GO BACK")) fileType = OPTIONS_FILE[fileInt] while fileInt != len(OPTIONS_FILE.keys()): fileNameOption = printOptions( addOption(OPTIONS_NAME, "GO BACK")) while fileNameOption != len(OPTIONS_NAME.keys()): if fileNameOption == 2: fileName = input( "\n\tWhat would you like to name your '{}' file? " .format(fileType)) else: fileName = fileNameGet(fileType) fileCreate(fileName, fileType) fileNameOption = len(OPTIONS_NAME.keys()) fileInt = len(OPTIONS_FILE) actionGet(options) elif option == 2: filesList(SUBFOLDERS) elif option == 3: filesByFolder = filesList(SUBFOLDERS) folderOpts, fileOpts = buildChoicesForFiles(filesByFolder) processChoicesForFiles(folderOpts, fileOpts) elif option == 4: configEdit() actionGet(options)
def fileNameGet(fileType): try: if type(fileType) == 'int' and fileType in OPTIONS_FILE.keys(): fileType = OPTIONS_FILE[fileType] chapter = int( input("\n\tWhat chapter is the {} file for? ".format(fileType))) exercise = int( input("\n\tWhat exercise is the {} file for? ".format(fileType))) dateOption = printOptions(OPTIONS_DATE) if dateOption == 1: dateString = getDateMANUAL() else: dateString = getDate() chapter = str(chapter).zfill(2) exercise = str(exercise).zfill(2) if chapter == "00" or exercise == "00": print("\n\t\tERROR: Please enter the proper information.") fileNameGet(fileType) return "ch" + chapter + ".ex" + exercise + "." + dateString + ".py" except ValueError: print( "\n\t\tERROR: Please enter a number for the Chapter and Excercise." ) fileNameGet(fileType)
def processChoicesForDates(dateOpts): print("\n For which date would you like to create an assignment file: ") dateChoice = printOptions(addOption(dateOpts, "GO BACK")) while dateChoice != len(dateOpts.keys()): dateString = dateOpts[dateChoice] assignmentsFilter(dateString)
import helpers running = True helpers.printIntro() helpers.printOptions() while running: userIn = input('\nType the currency symbol you want a rate for: \n> ') if (helpers.validateUserIn(userIn)): response = helpers.getCurrencies(userIn.upper()) print('\n' + response[0]["name"] + ' (' + response[0]["symbol"] + ') is currently evaluated at USD $' + helpers.roundValue(response[0]["price"]) + '.') check = input('Convert another coin? (Y/N):\n> ') if check.upper() == 'N' or check.upper() == 'NO': running = False else: print('\nWhoops! \'' + userIn + '\' wasn\'t valid input.') helpers.printOptions(); print('\n---------') print('Quitting...') print('Have a great day!') print('-dk')