mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Remove regex related to baby-JSON parsing only.
This commit is contained in:
parent
22dbb65b13
commit
d6e6d2a6ca
2 changed files with 1 additions and 4 deletions
|
@ -1129,11 +1129,10 @@ def filter_leading_non_json_lines(buf):
|
||||||
filter only leading lines since multiline JSON is valid.
|
filter only leading lines since multiline JSON is valid.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
kv_regex = re.compile(r'\w=\w')
|
|
||||||
filtered_lines = StringIO.StringIO()
|
filtered_lines = StringIO.StringIO()
|
||||||
stop_filtering = False
|
stop_filtering = False
|
||||||
for line in buf.splitlines():
|
for line in buf.splitlines():
|
||||||
if stop_filtering or line.startswith('{') or line.startswith('[') or kv_regex.search(line):
|
if stop_filtering or line.startswith('{') or line.startswith('['):
|
||||||
stop_filtering = True
|
stop_filtering = True
|
||||||
filtered_lines.write(line + '\n')
|
filtered_lines.write(line + '\n')
|
||||||
return filtered_lines.getvalue()
|
return filtered_lines.getvalue()
|
||||||
|
|
|
@ -453,8 +453,6 @@ class TestUtils(unittest.TestCase):
|
||||||
'{"foo": "bar"}\n')
|
'{"foo": "bar"}\n')
|
||||||
self.assertEqual(ansible.utils.filter_leading_non_json_lines('a\nb\nansible!\n["foo", "bar"]'),
|
self.assertEqual(ansible.utils.filter_leading_non_json_lines('a\nb\nansible!\n["foo", "bar"]'),
|
||||||
'["foo", "bar"]\n')
|
'["foo", "bar"]\n')
|
||||||
self.assertEqual(ansible.utils.filter_leading_non_json_lines('a\nb\nansible!\nfoo=bar'),
|
|
||||||
'foo=bar\n')
|
|
||||||
|
|
||||||
def test_boolean(self):
|
def test_boolean(self):
|
||||||
self.assertEqual(ansible.utils.boolean("true"), True)
|
self.assertEqual(ansible.utils.boolean("true"), True)
|
||||||
|
|
Loading…
Reference in a new issue