mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-22 08:59:08 -07:00
No need to specialcase comment characters
If the # is inside of quotes, it's a string. If it's outside of quotes then an exception will be raised which we'll catch and then send to the to_text() call at the end of the function anyhow. Fixes #22868
This commit is contained in:
parent
589e217278
commit
c7c8481181
1 changed files with 10 additions and 11 deletions
|
@ -327,17 +327,16 @@ class InventoryParser(object):
|
||||||
Attempt to transform the string value from an ini file into a basic python object
|
Attempt to transform the string value from an ini file into a basic python object
|
||||||
(int, dict, list, unicode string, etc).
|
(int, dict, list, unicode string, etc).
|
||||||
'''
|
'''
|
||||||
if "#" not in v:
|
try:
|
||||||
try:
|
v = ast.literal_eval(v)
|
||||||
v = ast.literal_eval(v)
|
# Using explicit exceptions.
|
||||||
# Using explicit exceptions.
|
# Likely a string that literal_eval does not like. We wil then just set it.
|
||||||
# Likely a string that literal_eval does not like. We wil then just set it.
|
except ValueError:
|
||||||
except ValueError:
|
# For some reason this was thought to be malformed.
|
||||||
# For some reason this was thought to be malformed.
|
pass
|
||||||
pass
|
except SyntaxError:
|
||||||
except SyntaxError:
|
# Is this a hash with an equals at the end?
|
||||||
# Is this a hash with an equals at the end?
|
pass
|
||||||
pass
|
|
||||||
return to_text(v, nonstring='passthru', errors='surrogate_or_strict')
|
return to_text(v, nonstring='passthru', errors='surrogate_or_strict')
|
||||||
|
|
||||||
def get_host_variables(self, host):
|
def get_host_variables(self, host):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue