def read_config(options, args, arglist, parser):
 config = RawConfigParser()
 cli_conf = options.config
 local_dir = os.curdir
 if (USER_CONFIG and os.path.isfile(USER_CONFIG)):
  if options.verbose:
   print ('user configuration: %s' % USER_CONFIG)
  config.read(USER_CONFIG)
 parent = tail = (args and os.path.abspath(os.path.commonprefix(args)))
 while tail:
  if config.read((os.path.join(parent, fn) for fn in PROJECT_CONFIG)):
   local_dir = parent
   if options.verbose:
    print ('local configuration: in %s' % parent)
   break
  (parent, tail) = os.path.split(parent)
 if (cli_conf and os.path.isfile(cli_conf)):
  if options.verbose:
   print ('cli configuration: %s' % cli_conf)
  config.read(cli_conf)
 pep8_section = parser.prog
 if config.has_section(pep8_section):
  option_list = dict([(o.dest, (o.type or o.action)) for o in parser.option_list])
  (new_options, __) = parser.parse_args([])
  for opt in config.options(pep8_section):
   if (opt.replace('_', '-') not in parser.config_options):
    print ("  unknown option '%s' ignored" % opt)
    continue
   if (options.verbose > 1):
    print ('  %s = %s' % (opt, config.get(pep8_section, opt)))
   normalized_opt = opt.replace('-', '_')
   opt_type = option_list[normalized_opt]
   if (opt_type in ('int', 'count')):
    value = config.getint(pep8_section, opt)
   elif (opt_type == 'string'):
    value = config.get(pep8_section, opt)
    if (normalized_opt == 'exclude'):
     value = normalize_paths(value, local_dir)
   else:
    assert (opt_type in ('store_true', 'store_false'))
    value = config.getboolean(pep8_section, opt)
   setattr(new_options, normalized_opt, value)
  (options, __) = parser.parse_args(arglist, values=new_options)
 options.doctest = options.testsuite = False
 return options

def read_config ( options , args , arglist , parser ) : config = RawConfigParser ( ) cli_conf = options . config local_dir = os . curdir if ( USER_CONFIG and os . path . isfile ( USER_CONFIG ) ) : if options . verbose : print ( 'user configuration: %s' % USER_CONFIG ) config . read ( USER_CONFIG ) parent = tail = ( args and os . path . abspath ( os . path . commonprefix ( args ) ) ) while tail : if config . read ( ( os . path . join ( parent , fn ) for fn in PROJECT_CONFIG ) ) : local_dir = parent if options . verbose : print ( 'local configuration: in %s' % parent ) break ( parent , tail ) = os . path . split ( parent ) if ( cli_conf and os . path . isfile ( cli_conf ) ) : if options . verbose : print ( 'cli configuration: %s' % cli_conf ) config . read ( cli_conf ) pep8_section = parser . prog if config . has_section ( pep8_section ) : option_list = dict ( [ ( o . dest , ( o . type or o . action ) ) for o in parser . option_list ] ) ( new_options , __ ) = parser . parse_args ( [ ] ) for opt in config . options ( pep8_section ) : if ( opt . replace ( '_' , '-' ) not in parser . config_options ) : print ( "  unknown option '%s' ignored" % opt ) continue if ( options . verbose > 1 ) : print ( '  %s = %s' % ( opt , config . get ( pep8_section , opt ) ) ) normalized_opt = opt . replace ( '-' , '_' ) opt_type = option_list [ normalized_opt ] if ( opt_type in ( 'int' , 'count' ) ) : value = config . getint ( pep8_section , opt ) elif ( opt_type == 'string' ) : value = config . get ( pep8_section , opt ) if ( normalized_opt == 'exclude' ) : value = normalize_paths ( value , local_dir ) else : assert ( opt_type in ( 'store_true' , 'store_false' ) ) value = config . getboolean ( pep8_section , opt ) setattr ( new_options , normalized_opt , value ) ( options , __ ) = parser . parse_args ( arglist , values = new_options ) options . doctest = options . testsuite = False return options
reads pylintrc config onto native configparser object .