diff options
author | Kristian Glass <git@doismellburning.co.uk> | 2015-08-22 17:32:15 +0100 |
---|---|---|
committer | Kristian Glass <git@doismellburning.co.uk> | 2015-08-22 17:32:15 +0100 |
commit | e7d64d3062421707a1c896b25cc5134922bcd9ee (patch) | |
tree | f99ed0fb6ead6415707d0a0d71f9e93fa1b353f9 | |
parent | 8aac6b5cc3fc2fba33c5a9108feae97e7907ce9b (diff) | |
download | pep8-e7d64d3062421707a1c896b25cc5134922bcd9ee.tar.gz |
Improved parsing of multiline option values (including trailing commas)
-rwxr-xr-x | pep8.py | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -2081,10 +2081,10 @@ def process_options(arglist=None, parse_argv=False, config_file=None, options = read_config(options, args, arglist, parser) options.reporter = parse_argv and options.quiet == 1 and FileReport - options.filename = options.filename and options.filename.split(',') + options.filename = _parse_multi_options(options.filename.split(',')) options.exclude = normalize_paths(options.exclude) - options.select = options.select and options.select.split(',') - options.ignore = options.ignore and options.ignore.split(',') + options.select = _parse_multi_options(options.select.split(',')) + options.ignore = _parse_multi_options(options.ignore.split(',')) if options.diff: options.reporter = DiffReport @@ -2095,6 +2095,22 @@ def process_options(arglist=None, parse_argv=False, config_file=None, return options, args +def _parse_multi_options(options): + r"""Split and strip and discard empties. + + Turns the following: + + A, + B, + + into ["A", "B"] + """ + if options: + return [o.strip() for o in options if o.strip()] + else: + return options + + def _main(): """Parse options and run checks on Python source.""" import signal |