mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 13:06:53 +00:00
Start fleshing out flake8.utils
Add parse_comma_separated_list, normalize_path, and normalize_paths and add logic in OptionManager.parse_args to use the right normalize_path* function based on comma_separated_list value of the option.
This commit is contained in:
parent
ad0200e792
commit
a4042d6d69
3 changed files with 81 additions and 8 deletions
|
|
@ -150,13 +150,22 @@ class OptionManager(object):
|
|||
"""Simple proxy to calling the OptionParser's parse_args method."""
|
||||
options, xargs = self.parser.parse_args(args, values)
|
||||
for option in self.options:
|
||||
dest = option.dest
|
||||
if option.normalize_paths:
|
||||
old_value = getattr(options, dest)
|
||||
setattr(options, dest, utils.normalize_paths(old_value))
|
||||
elif option.comma_separated_list:
|
||||
old_value = getattr(options, dest)
|
||||
setattr(options, dest,
|
||||
utils.parse_comma_separated_list(old_value))
|
||||
_normalize_option(options, option)
|
||||
|
||||
return options, xargs
|
||||
|
||||
|
||||
def _normalize_option(options, option):
|
||||
dest = option.dest
|
||||
if option.normalize_paths:
|
||||
old_value = getattr(options, dest)
|
||||
# Decide whether to parse a list of paths or a single path
|
||||
normalize = utils.normalize_path
|
||||
if option.comma_separated_list:
|
||||
normalize = utils.normalize_paths
|
||||
setattr(options, dest, normalize(old_value))
|
||||
|
||||
elif option.comma_separated_list:
|
||||
old_value = getattr(options, dest)
|
||||
setattr(options, dest,
|
||||
utils.parse_comma_separated_list(old_value))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue