|
55 | 55 | import sys
|
56 | 56 | import time
|
57 | 57 | import tokenize
|
| 58 | +import warnings |
58 | 59 |
|
59 | 60 | from fnmatch import fnmatch
|
60 | 61 | from optparse import OptionParser
|
@@ -2144,29 +2145,36 @@ def read_config(options, args, arglist, parser):
|
2144 | 2145 | print('cli configuration: %s' % cli_conf)
|
2145 | 2146 | config.read(cli_conf)
|
2146 | 2147 |
|
2147 |
| - pep8_section = parser.prog |
2148 |
| - if config.has_section(pep8_section): |
| 2148 | + pycodestyle_section = None |
| 2149 | + if config.has_section(parser.prog): |
| 2150 | + pycodestyle_section = parser.prog |
| 2151 | + elif config.has_section('pep8'): |
| 2152 | + pycodestyle_section = 'pep8' # Deprecated |
| 2153 | + warnings.warn('[pep8] section is deprecated. Use [pycodestyle].') |
| 2154 | + |
| 2155 | + if pycodestyle_section: |
2149 | 2156 | option_list = dict([(o.dest, o.type or o.action)
|
2150 | 2157 | for o in parser.option_list])
|
2151 | 2158 |
|
2152 | 2159 | # First, read the default values
|
2153 | 2160 | (new_options, __) = parser.parse_args([])
|
2154 | 2161 |
|
2155 | 2162 | # Second, parse the configuration
|
2156 |
| - for opt in config.options(pep8_section): |
| 2163 | + for opt in config.options(pycodestyle_section): |
2157 | 2164 | if opt.replace('_', '-') not in parser.config_options:
|
2158 | 2165 | print(" unknown option '%s' ignored" % opt)
|
2159 | 2166 | continue
|
2160 | 2167 | if options.verbose > 1:
|
2161 |
| - print(" %s = %s" % (opt, config.get(pep8_section, opt))) |
| 2168 | + print(" %s = %s" % (opt, |
| 2169 | + config.get(pycodestyle_section, opt))) |
2162 | 2170 | normalized_opt = opt.replace('-', '_')
|
2163 | 2171 | opt_type = option_list[normalized_opt]
|
2164 | 2172 | if opt_type in ('int', 'count'):
|
2165 |
| - value = config.getint(pep8_section, opt) |
| 2173 | + value = config.getint(pycodestyle_section, opt) |
2166 | 2174 | elif opt_type in ('store_true', 'store_false'):
|
2167 |
| - value = config.getboolean(pep8_section, opt) |
| 2175 | + value = config.getboolean(pycodestyle_section, opt) |
2168 | 2176 | else:
|
2169 |
| - value = config.get(pep8_section, opt) |
| 2177 | + value = config.get(pycodestyle_section, opt) |
2170 | 2178 | if normalized_opt == 'exclude':
|
2171 | 2179 | value = normalize_paths(value, local_dir)
|
2172 | 2180 | setattr(new_options, normalized_opt, value)
|
|
0 commit comments