def process_options(arglist=None):
    """
    Process options passed either via arglist or via command line args.
    """
    global options, args
    usage = "%prog [options] input ..."
    parser = OptionParser(usage)
    parser.add_option('-v', '--verbose', default=0, action='count',
                      help="print status messages, or debug with -vv")
    parser.add_option('-q', '--quiet', default=0, action='count',
                      help="report only file names, or nothing with -qq")
    parser.add_option('--exclude', metavar='patterns', default=default_exclude,
                      help="skip matches (default %s)" % default_exclude)
    parser.add_option('--filename', metavar='patterns',
                      help="only check matching files (e.g. *.py)")
    parser.add_option('--ignore', metavar='errors', default='',
                      help="skip errors and warnings (e.g. E4,W)")
    parser.add_option('--repeat', action='store_true',
                      help="show all occurrences of the same error")
    parser.add_option('--show-source', action='store_true',
                      help="show source code for each error")
    parser.add_option('--show-pep8', action='store_true',
                      help="show text of PEP 8 for each error")
    parser.add_option('--statistics', action='store_true',
                      help="count errors and warnings")
    parser.add_option('--benchmark', action='store_true',
                      help="measure processing speed")
    parser.add_option('--testsuite', metavar='dir',
                      help="run regression tests from dir")
    parser.add_option('--doctest', action='store_true',
                      help="run doctest on myself")
    options, args = parser.parse_args(arglist)
    if options.testsuite:
        args.append(options.testsuite)
    if len(args) == 0:
        parser.error('input not specified')
    options.prog = os.path.basename(sys.argv[0])
    options.exclude = options.exclude.split(',')
    for index in range(len(options.exclude)):
        options.exclude[index] = options.exclude[index].rstrip('/')
    if options.filename:
        options.filename = options.filename.split(',')
    if options.ignore:
        options.ignore = options.ignore.split(',')
    else:
        options.ignore = []
    options.counters = {}
    options.messages = {}

    return options, args
def process_options ( arglist = None ) : global options , args usage = "%prog [options] input ..." parser = OptionParser ( usage ) parser . add_option ( '-v' , '--verbose' , default = 0 , action = 'count' , help = "print status messages, or debug with -vv" ) parser . add_option ( '-q' , '--quiet' , default = 0 , action = 'count' , help = "report only file names, or nothing with -qq" ) parser . add_option ( '--exclude' , metavar = 'patterns' , default = default_exclude , help = "skip matches (default %s)" % default_exclude ) parser . add_option ( '--filename' , metavar = 'patterns' , help = "only check matching files (e.g. *.py)" ) parser . add_option ( '--ignore' , metavar = 'errors' , default = '' , help = "skip errors and warnings (e.g. E4,W)" ) parser . add_option ( '--repeat' , action = 'store_true' , help = "show all occurrences of the same error" ) parser . add_option ( '--show-source' , action = 'store_true' , help = "show source code for each error" ) parser . add_option ( '--show-pep8' , action = 'store_true' , help = "show text of PEP 8 for each error" ) parser . add_option ( '--statistics' , action = 'store_true' , help = "count errors and warnings" ) parser . add_option ( '--benchmark' , action = 'store_true' , help = "measure processing speed" ) parser . add_option ( '--testsuite' , metavar = 'dir' , help = "run regression tests from dir" ) parser . add_option ( '--doctest' , action = 'store_true' , help = "run doctest on myself" ) options , args = parser . parse_args ( arglist ) if options . testsuite : args . append ( options . testsuite ) if len ( args ) == 0 : parser . error ( 'input not specified' ) options . prog = os . path . basename ( sys . argv [ 0 ] ) options . exclude = options . exclude . split ( ',' ) for index in range ( len ( options . exclude ) ) : options . exclude [ index ] = options . exclude [ index ] . rstrip ( '/' ) if options . filename : options . filename = options . filename . split ( ',' ) if options . ignore : options . ignore = options . ignore . split ( ',' ) else : options . ignore = [ ] options . counters = { } options . messages = { } return options , args
Process options passed either via arglist or via command line args.