diff options
author | Michael Scherer <misc@redhat.com> | 2016-10-16 16:40:45 +0200 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2016-10-17 12:11:34 -0700 |
commit | b0159fe7d364d2268d32a8da00795b44ffac58c4 (patch) | |
tree | c4a4a430f9af7679866b69b9e3e12bf855701378 | |
parent | d018a86f4f1851351b9c2eb2456849c600ce059c (diff) | |
download | ansible-modules-core-b0159fe7d364d2268d32a8da00795b44ffac58c4.tar.gz |
Remove the wide try/expect clause
This doesn't catch anything precise, and none of the methods should
throw a expection for anything. This also hide python 3 errors.
-rw-r--r-- | system/authorized_key.py | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/system/authorized_key.py b/system/authorized_key.py index 4b042070..09e4bf30 100644 --- a/system/authorized_key.py +++ b/system/authorized_key.py @@ -243,25 +243,22 @@ def parseoptions(module, options): ''' options_dict = keydict() #ordered dict if options: - try: - # the following regex will split on commas while - # ignoring those commas that fall within quotes - regex = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''') - parts = regex.split(options)[1:-1] - for part in parts: - if "=" in part: - (key, value) = part.split("=", 1) - if options_dict.has_key(key): - if isinstance(options_dict[key], list): - options_dict[key].append(value) - else: - options_dict[key] = [options_dict[key], value] + # the following regex will split on commas while + # ignoring those commas that fall within quotes + regex = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''') + parts = regex.split(options)[1:-1] + for part in parts: + if "=" in part: + (key, value) = part.split("=", 1) + if options_dict.has_key(key): + if isinstance(options_dict[key], list): + options_dict[key].append(value) else: - options_dict[key] = value - elif part != ",": - options_dict[part] = None - except: - module.fail_json(msg="invalid option string: %s" % options) + options_dict[key] = [options_dict[key], value] + else: + options_dict[key] = value + elif part != ",": + options_dict[part] = None return options_dict |