本文整理汇总了Python中Output.getNumResults方法的典型用法代码示例。如果您正苦于以下问题:Python Output.getNumResults方法的具体用法?Python Output.getNumResults怎么用?Python Output.getNumResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Output
的用法示例。
在下文中一共展示了Output.getNumResults方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: writeSearchHistory
# 需要导入模块: import Output [as 别名]
# 或者: from Output import getNumResults [as 别名]
def writeSearchHistory(fastSearchDir, string, optionsList, results, time):
# if the file already exists, append to it, otherwise create it
if os.path.exists(fastSearchDir + 'Support' + os.sep + recentSearchesFileName):
recentSearchesFile = open(fastSearchDir + 'Support' + os.sep + recentSearchesFileName, 'a')
else:
recentSearchesFile = open(fastSearchDir + 'Support' + os.sep + recentSearchesFileName, 'w')
numResults = Output.getNumResults(results)
if numResults > 0:
recentSearchesFile.write('-----------------------------\n')
recentSearchesFile.write('Date and Time: ' + strftime("%Y-%m-%d %H:%M:%S") + '\n')
recentSearchesFile.write('Root Directory: ' + optionsList[5] + '\n')
recentSearchesFile.write('Search String: ' + string + '\n')
recentSearchesFile.write('Search Time: ' + str(time) + '\n')
recentSearchesFile.write('Result Count: ' + str(numResults) + '\n')
recentSearchesFile.write('\n--Results--')
# scan through and print the full path for each folder result (if folders are displayed)
if optionsList[1] == 1 or optionsList[1] == 2:
recentSearchesFile.write('\n\n::Matching Folder Names::')
if len(results[0]) != 0:
for item in results[0]:
recentSearchesFile.write('\n' + item)
else:
recentSearchesFile.write('\n-None Found-')
# scan through and print full paths for each file result (if files are displayed)
if optionsList[1] == 0 or optionsList[1] == 2:
recentSearchesFile.write('\n\n::Matching File Names::')
if len(results[1]) != 0:
for item in results[1]:
recentSearchesFile.write('\n' + item)
else:
recentSearchesFile.write('\n-None Found-')
# scan through and print full paths for each file the string was found within (if a deep search was run)
if optionsList[0]:
recentSearchesFile.write('\n\n::Found in Files::')
if len(results[2]) != 0:
for item in results[2]:
recentSearchesFile.write('\n' + item[0] + '\n On Line%s: ' % (len(item[1]) != 1 and 's' or '') + str(item[1]))
else:
recentSearchesFile.write('\n-None Found-')
recentSearchesFile.write('\n-----------------------------\n\n')
recentSearchesFile.close()