def results(path, string, optionsList, results, time, colors): numResults = getNumResults(results) # display how many items were found in how many seconds (rounded to two decimals) a ternary operation is emulated # for the potential pluralization of 'Result(s)' print colors.green() + '--FastSearch Found \'' + string + '\' ' + str(numResults) + ' Time%s in ' % (numResults != 1 and 's' or '') \ + optionsList[5] + ' in ' + str(round(time, 2)) + ' Seconds--' + colors.end() # a full search was performed if optionsList[4]: itemNum = 1 # scan through and print the full path for each folder result (if folders are displayed) if optionsList[1] == 1 or optionsList[1] == 2: print colors.green() + '\n::Matching Folder Names::' + colors.end() if len(results[0]) != 0: for item in results[0]: print colors.green() + '[' + str(itemNum) + ']: ' + item + colors.end() itemNum += 1 else: print colors.alert() + '-None Found-' + colors.end() # scan through and print full paths for each file result (if files are displayed) if optionsList[1] == 0 or optionsList[1] == 2: print colors.green() + '\n::Matching File Names::' + colors.end() if len(results[1]) != 0: for item in results[1]: print colors.green() + '[' + str(itemNum) + ']: ' + item + colors.end() itemNum += 1 else: print colors.alert() + '-None Found-' + colors.end() # scan through and print full paths for each file the string was found within (if a deep search was run) if optionsList[0]: print colors.green() + '\n::Found in Files::' + colors.end() if len(results[2]) != 0: for item in results[2]: print colors.green() + '[' + str(itemNum) + ']: ' + item[0] + '\n On Line%s: ' % (len(item[1]) != 1 and 's' or '') + str(item[1]) + colors.end() itemNum += 1 else: print colors.alert() + '-None Found-' + colors.end() # a partial search was performed else: # print the only folder found if optionsList[1] == 1 or optionsList[1] == 2: print colors.green() + '\n::Matching Folder::' + colors.end() if len(results[0]) != 0: print colors.green() + '[1]: ' + results[0][0] + colors.end() else: print colors.alert() + '-None Found-' + colors.end() # print the only file found if optionsList[1] == 0 or optionsList[1] == 2: print colors.green() + '\n::Matching File::' + colors.end() if len(results[1]) != 0: print colors.green() + '[1]: ' + results[1][0] + colors.end() else: print colors.alert() + '-None Found-' + colors.end() # print the only file the string was found within if optionsList[0]: print colors.green() + '\n::Found in File::' + colors.end() if len(results[2]) != 0: print colors.green() + '[1]: ' + results[2][0][0] + '\n On Line%s: ' % (len(results[2][0][1]) != 1 and 's' or '') + str(results[2][0][1]) + colors.end() else: print colors.alert() + '-None Found-' + colors.end() # if the user desires, write this to the recent searches list if optionsList[8]: FileHandler.writeSearchHistory(path, string, optionsList, results, time) if os.name == 'posix': print colors.alert() + '\n--To open a search result, type its corresponding number from the main menu--\n' + colors.end()