diff options
author | Michael DeHaan <michael.dehaan@gmail.com> | 2012-03-31 04:52:38 +0200 |
---|---|---|
committer | Michael DeHaan <michael.dehaan@gmail.com> | 2012-03-31 04:52:38 +0200 |
commit | 9569be8bdbecf104a0faa27e0ed9b5c19538bda2 (patch) | |
tree | 98d68d46b45f5003612b9e57f87c04c90fc050c8 | |
parent | Treat module args as strings everywhere to avoid unneccessary shlex and requo... (diff) | |
download | ansible-9569be8bdbecf104a0faa27e0ed9b5c19538bda2.tar.xz ansible-9569be8bdbecf104a0faa27e0ed9b5c19538bda2.zip |
Need for quoting/unquoting problems go away once module_args are all treated as strings throughout.
-rwxr-xr-x | lib/ansible/utils.py | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py index 5cd3dff380..e061d6d0f2 100755 --- a/lib/ansible/utils.py +++ b/lib/ansible/utils.py @@ -260,29 +260,13 @@ def parse_yaml_from_file(path): raise errors.AnsibleError("file not found: %s" % path) return parse_yaml(data) -def unquote_string(string): - ''' 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): +def parse_kv(args): ''' convert a string of key/value items to a dict ''' options = {} - # FIXME: this should be mostly unneccessary once we convert - # things to stop parsing/unparsing - if type(args) == list: - vargs = args - else: - vargs = shlex.split(args, posix=True) + vargs = shlex.split(args, posix=True) for x in vargs: if x.find("=") != -1: k, v = x.split("=") - if unquote: - options[k]=unquote_string(v) - else: - v + options[k]=v return options |