1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-21 00:19:42 +02:00

use shlex split for values within quotations that have spaces

This commit is contained in:
Kelly Brazil
2020-02-28 09:07:36 -08:00
parent 79522d1c7d
commit 8f954673ab

View File

@ -74,6 +74,7 @@ Examples:
}
]
"""
import shlex
import jc.utils
@ -183,12 +184,12 @@ def parse(data, raw=False, quiet=False):
for line in linedata:
output_line = {}
entries = line.split()
entries = shlex.split(line)
output_line['device'] = entries.pop(0)[:-1]
for entry in entries:
key = entry.split('=')[0].lower()
value = entry.split('=')[1].replace('"', '')
value = entry.split('=')[1]
output_line[key] = value
raw_output.append(output_line)