mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Merge pull request #46197 from terminalmage/split-input-map
Add mapper to salt.utils.args.split_input()
This commit is contained in:
commit
218c2af39d
@ -14,7 +14,7 @@ import shlex
|
||||
# Import salt libs
|
||||
from salt.exceptions import SaltInvocationError
|
||||
from salt.ext import six
|
||||
from salt.ext.six.moves import zip # pylint: disable=import-error,redefined-builtin
|
||||
from salt.ext.six.moves import map, zip # pylint: disable=import-error,redefined-builtin
|
||||
import salt.utils.data
|
||||
import salt.utils.jid
|
||||
import salt.utils.versions
|
||||
@ -339,16 +339,18 @@ def argspec_report(functions, module=''):
|
||||
return ret
|
||||
|
||||
|
||||
def split_input(val):
|
||||
def split_input(val, mapper=None):
|
||||
'''
|
||||
Take an input value and split it into a list, returning the resulting list
|
||||
'''
|
||||
if mapper is None:
|
||||
mapper = lambda x: x
|
||||
if isinstance(val, list):
|
||||
return val
|
||||
return list(map(mapper, val))
|
||||
try:
|
||||
return [x.strip() for x in val.split(',')]
|
||||
return list(map(mapper, [x.strip() for x in val.split(',')]))
|
||||
except AttributeError:
|
||||
return [x.strip() for x in six.text_type(val).split(',')]
|
||||
return list(map(mapper, [x.strip() for x in six.text_type(val).split(',')]))
|
||||
|
||||
|
||||
def test_mode(**kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user