当前位置: 首页>>代码示例>>Python>>正文


Python Output.help方法代码示例

本文整理汇总了Python中Output.help方法的典型用法代码示例。如果您正苦于以下问题:Python Output.help方法的具体用法?Python Output.help怎么用?Python Output.help使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Output的用法示例。


在下文中一共展示了Output.help方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import Output [as 别名]
# 或者: from Output import help [as 别名]
def main(args):
    # get the absolute path of the FastSearch directory
    fastSearchDir = os.path.abspath(args[0])[:os.path.abspath(args[0]).rfind(os.sep)] + os.sep
    
    # instantiate the exit code
    code = EXIT_CLEAN
    
    # instantiate pre-run update condition
    preRunUpdateCheck = False
    
    # declare options list
    optionsList = FileHandler.initializeOptionsList(fastSearchDir, [])
    colors = Output.Colors(optionsList)
    
    # FastSearch has been updated
    if len(args) > 3 and args[1] == '-updatesuccess':
        print colors.alert() + '\nFastSearch has been successfully updated to v' + str(Updater.CURRENT_VERSION) + '!' + colors.end()
        # display the post update message retrieved from the server
        if not (args[2] in ('None', '', None)):
            print colors.alert() + args[2:] + colors.end()
    
    # run a QuickSearch and return the results as a list and quit the application
    if len(args) > 1 and args[1][1:].lower() in ('r', 'return'):
        if len(args) > 2:
            optionsList = FileHandler.defaultList
            if len(args) > 3 and args[2][1:].lower() in ('d', 'deep', 'deepsearch', 'ds'):
                optionsList[0] = True
                start = 3
            else:
                start = 2
            
            # if the user requested a deep search but provided no string
            if args[start][1:] in ('d', 'deep', 'deepsearch', 'ds'):
                return EXIT_RESULTS_BAD, None
            
            string = args[start].lower()            
            for i in range(start + 1, len(args)):
                string += ' ' + args[i].lower()
            
            search = Search.Search(string, optionsList, colors)
            search.start()
            search.join()
            return EXIT_RESULTS, search.finish()
        else:
            return EXIT_RESULTS_BAD, None
    
    print colors.blue() + '\n::Welcome to FastSearch v' + str(Updater.CURRENT_VERSION) + ' by Alex Laird::' + colors.end()
    
    # if arguments are specified, use them as the search string
    if len(args) > 1 and not args[1] == '-updatesuccess':
        if args[1].startswith('-'):
            if len(args) == 2 and not args[1][1:].lower() in ('d', 'debug'):
                if args[1][1:].lower() in ('help', 'h'):
                    Output.help(colors)
                elif args[1][1:].lower() in ('update', 'updates', 'u'):
                    runUpdater(fastSearchDir, colors)
                elif args[1][1:].lower() in ('credit', 'credits', 'c'):
                    Output.credits(colors)
                elif args[1][1:].lower() in ('option', 'options', 'o', 'pref', 'preferences', 'setting', 'settings'):
                    optionsList = Options.options(fastSearchDir, optionsList, colors)
                else:
                    print colors.alert() + 'The command-line arguments were not valid. View the help menu for assistance.\n' + colors.end()
            # run a benchmark comparing a standard os.walk method (with no comparisons) to the FastSearch localWalk method
            elif args[1][1:].lower() in ('d', 'debug'):
                try:
                    code = debug(args, colors)
                except:
                    code = EXIT_DEBUG_ERROR
                
                return code
            else:
                print colors.alert() + 'The command-line arguments were not valid. View the help menu for assistance.\n' + colors.end()
        else:
            string = args[1].lower()
            for i in range(2, len(args)):
                string += ' ' + args[i].lower()
    
            # the search will be launched immedietly with the current working directory as root
            code = runSearch(fastSearchDir, string, optionsList, False, colors)[0]
    # if no arguments were specified
    elif len(args) == 1:
        if preRunUpdateCheck:
            simpleUpdateChecker(colors)

    looping = True
    results = None
        
    # loop until the user wants out
    while looping:
        # retreive a command from the user
        string = raw_input(colors.blue() + 'Type (s)earch, (o)ptions, (u)pdate, (h)elp, (c)redits, or (q)uit: ' + colors.end()).lower()
        
        # the user entered a number
        if string.strip('[]').isdigit():
            if not results == None:
                location = int(string.strip('[]')) - 1
                ref = 0
                # decrement the number as needed to keep it consistent with the correct results subarray
                if location > len(results[0]) - 1:
                    location -= len(results[0])
#.........这里部分代码省略.........
开发者ID:alexdlaird,项目名称:fastsearch,代码行数:103,代码来源:FastSearch.py


注:本文中的Output.help方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。