From 1350a34316d912ac37c6857d142f75db589c497c Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 5 Jan 2023 16:59:22 -0800 Subject: [PATCH] beautify process function --- jc/parsers/kv.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/jc/parsers/kv.py b/jc/parsers/kv.py index de1b4421..f7e6420a 100644 --- a/jc/parsers/kv.py +++ b/jc/parsers/kv.py @@ -82,15 +82,15 @@ def _process(proc_data): """ # remove quotation marks from beginning and end of values for key in proc_data: - if proc_data[key] is not None and proc_data[key].startswith('"') and proc_data[key].endswith('"'): - proc_data[key] = proc_data[key][1:-1] - - elif proc_data[key] is not None and proc_data[key].startswith("'") and proc_data[key].endswith("'"): - proc_data[key] = proc_data[key][1:-1] - - elif proc_data[key] is None: + if proc_data[key] is None: proc_data[key] = '' + elif proc_data[key].startswith('"') and proc_data[key].endswith('"'): + proc_data[key] = proc_data[key][1:-1] + + elif proc_data[key].startswith("'") and proc_data[key].endswith("'"): + proc_data[key] = proc_data[key][1:-1] + return proc_data @@ -130,8 +130,5 @@ def parse(data, raw=False, quiet=False): for key, value in output_dict['data'].items(): raw_output[key] = value - if raw: - return raw_output - else: - return _process(raw_output) + return raw_output if raw else _process(raw_output)