diff options
author | Thomas Schultz <daspecster@gmail.com> | 2016-11-03 13:39:10 -0400 |
---|---|---|
committer | Thomas Schultz <daspecster@gmail.com> | 2016-11-03 13:39:10 -0400 |
commit | 2cc7a8abce1f5442dc0d23da546752dcb611bc23 (patch) | |
tree | 41d26775b5fec2597e2e93b6072f3d29ef2b5c01 | |
parent | 5c4ca67b970258cd4c5ab0e36967b81255911fdb (diff) | |
download | pep8-2cc7a8abce1f5442dc0d23da546752dcb611bc23.tar.gz |
Check for both [pep8] and [pycodestyle] config sections.
-rwxr-xr-x | pycodestyle.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index a14369e..64a57ec 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -55,6 +55,7 @@ import re import sys import time import tokenize +import warnings from fnmatch import fnmatch from optparse import OptionParser @@ -2144,8 +2145,14 @@ def read_config(options, args, arglist, parser): print('cli configuration: %s' % cli_conf) config.read(cli_conf) - pep8_section = parser.prog - if config.has_section(pep8_section): + pycodestyle_section = None + if config.has_section(parser.prog): + pycodestyle_section = parser.prog + elif config.has_section('pep8'): + pycodestyle_section = 'pep8' # Deprecated + warnings.warn('[pep8] section is deprecated. Use [pycodestyle].') + + if pycodestyle_section: option_list = dict([(o.dest, o.type or o.action) for o in parser.option_list]) @@ -2153,20 +2160,21 @@ def read_config(options, args, arglist, parser): (new_options, __) = parser.parse_args([]) # Second, parse the configuration - for opt in config.options(pep8_section): + for opt in config.options(pycodestyle_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))) + print(" %s = %s" % (opt, + config.get(pycodestyle_section, opt))) normalized_opt = opt.replace('-', '_') opt_type = option_list[normalized_opt] if opt_type in ('int', 'count'): - value = config.getint(pep8_section, opt) + value = config.getint(pycodestyle_section, opt) elif opt_type in ('store_true', 'store_false'): - value = config.getboolean(pep8_section, opt) + value = config.getboolean(pycodestyle_section, opt) else: - value = config.get(pep8_section, opt) + value = config.get(pycodestyle_section, opt) if normalized_opt == 'exclude': value = normalize_paths(value, local_dir) setattr(new_options, normalized_opt, value) |