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.
This commit is contained in:
parent
adc56e52d8
commit
c9da5e98a9
1 changed files with 15 additions and 18 deletions
|
@ -243,25 +243,22 @@ def parseoptions(module, options):
|
||||||
'''
|
'''
|
||||||
options_dict = keydict() #ordered dict
|
options_dict = keydict() #ordered dict
|
||||||
if options:
|
if options:
|
||||||
try:
|
# the following regex will split on commas while
|
||||||
# the following regex will split on commas while
|
# ignoring those commas that fall within quotes
|
||||||
# ignoring those commas that fall within quotes
|
regex = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''')
|
||||||
regex = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''')
|
parts = regex.split(options)[1:-1]
|
||||||
parts = regex.split(options)[1:-1]
|
for part in parts:
|
||||||
for part in parts:
|
if "=" in part:
|
||||||
if "=" in part:
|
(key, value) = part.split("=", 1)
|
||||||
(key, value) = part.split("=", 1)
|
if options_dict.has_key(key):
|
||||||
if options_dict.has_key(key):
|
if isinstance(options_dict[key], list):
|
||||||
if isinstance(options_dict[key], list):
|
options_dict[key].append(value)
|
||||||
options_dict[key].append(value)
|
|
||||||
else:
|
|
||||||
options_dict[key] = [options_dict[key], value]
|
|
||||||
else:
|
else:
|
||||||
options_dict[key] = value
|
options_dict[key] = [options_dict[key], value]
|
||||||
elif part != ",":
|
else:
|
||||||
options_dict[part] = None
|
options_dict[key] = value
|
||||||
except:
|
elif part != ",":
|
||||||
module.fail_json(msg="invalid option string: %s" % options)
|
options_dict[part] = None
|
||||||
|
|
||||||
return options_dict
|
return options_dict
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue