def read_config(options, args, arglist, parser):
    config = RawConfigParser()

    user_conf = options.config
    if user_conf and os.path.isfile(user_conf):
        if options.verbose:
            print(('user configuration: %s' % user_conf))
        config.read(user_conf)

    parent = tail = args and os.path.abspath(os.path.commonprefix(args))
    while tail:
        local_conf = os.path.join(parent, '.pep8')
        if os.path.isfile(local_conf):
            if options.verbose:
                print(('local configuration: %s' % local_conf))
            config.read(local_conf)
            break
        parent, tail = os.path.split(parent)

    if config.has_section('pep8'):
        option_list = dict([(o.dest, o.type or o.action)
                            for o in parser.option_list])

        # First, read the default values
        new_options, _ = parser.parse_args([])

        # Second, parse the configuration
        for opt in config.options('pep8'):
            if options.verbose > 1:
                print(('  %s = %s' % (opt, config.get('pep8', opt))))
            if opt.replace('_', '-') not in parser.config_options:
                print(('Unknown option: \'%s\'\n  not in [%s]' %
                      (opt, ' '.join(parser.config_options))))
                sys.exit(1)
            normalized_opt = opt.replace('-', '_')
            opt_type = option_list[normalized_opt]
            if opt_type in ('int', 'count'):
                value = config.getint('pep8', opt)
            elif opt_type == 'string':
                value = config.get('pep8', opt)
            else:
                assert opt_type in ('store_true', 'store_false')
                value = config.getboolean('pep8', opt)
            setattr(new_options, normalized_opt, value)

        # Third, overwrite with the command-line options
        options, _ = parser.parse_args(arglist, values=new_options)

    return options
Read both user configuration and local configuration.
dataset/ETHPy150Open kivy/plyer/plyer/tools/pep8checker/pep8.py/read_config