mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Need for quoting/unquoting problems go away once module_args are all treated as strings throughout.
This commit is contained in:
parent
3ded27fe35
commit
9569be8bdb
1 changed files with 3 additions and 19 deletions
|
@ -260,29 +260,13 @@ def parse_yaml_from_file(path):
|
||||||
raise errors.AnsibleError("file not found: %s" % path)
|
raise errors.AnsibleError("file not found: %s" % path)
|
||||||
return parse_yaml(data)
|
return parse_yaml(data)
|
||||||
|
|
||||||
def unquote_string(string):
|
def parse_kv(args):
|
||||||
''' remove single or double quotes from beginning/end of string'''
|
|
||||||
if (string.startswith('"') and string.endswith('"')) or \
|
|
||||||
(string.startswith("'") and string.endswith("'")):
|
|
||||||
return string[1:-1]
|
|
||||||
else:
|
|
||||||
return string
|
|
||||||
|
|
||||||
def parse_kv(args, unquote=True):
|
|
||||||
''' convert a string of key/value items to a dict '''
|
''' convert a string of key/value items to a dict '''
|
||||||
options = {}
|
options = {}
|
||||||
# FIXME: this should be mostly unneccessary once we convert
|
vargs = shlex.split(args, posix=True)
|
||||||
# things to stop parsing/unparsing
|
|
||||||
if type(args) == list:
|
|
||||||
vargs = args
|
|
||||||
else:
|
|
||||||
vargs = shlex.split(args, posix=True)
|
|
||||||
for x in vargs:
|
for x in vargs:
|
||||||
if x.find("=") != -1:
|
if x.find("=") != -1:
|
||||||
k, v = x.split("=")
|
k, v = x.split("=")
|
||||||
if unquote:
|
options[k]=v
|
||||||
options[k]=unquote_string(v)
|
|
||||||
else:
|
|
||||||
v
|
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue