Ignore empty entries in _list_from_options_callback

This commit is contained in:
pukkandan 2021-09-24 05:10:33 +05:30
parent 77c4a9ef68
commit 1f8471e22c
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698

View file

@ -119,7 +119,7 @@ def parseOpts(overrideArguments=None):
def _list_from_options_callback(option, opt_str, value, parser, append=True, delim=',', process=str.strip): def _list_from_options_callback(option, opt_str, value, parser, append=True, delim=',', process=str.strip):
# append can be True, False or -1 (prepend) # append can be True, False or -1 (prepend)
current = getattr(parser.values, option.dest) if append else [] current = getattr(parser.values, option.dest) if append else []
value = [process(value)] if delim is None else list(map(process, value.split(delim))) value = list(filter(None, [process(value)] if delim is None else map(process, value.split(delim))))
setattr( setattr(
parser.values, option.dest, parser.values, option.dest,
current + value if append is True else value + current) current + value if append is True else value + current)