From c94f5d83fa9b0efe33ba031ef62c4dd62457bdf6 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Tue, 3 Jan 2023 13:26:52 -0800 Subject: [PATCH] fix kv and ini parsers to only remove 1 quote from beginning and end --- CHANGELOG | 2 ++ jc/parsers/ini.py | 4 ++-- jc/parsers/kv.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fd76a3ae..558479b3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,8 @@ jc changelog 20230103 v1.22.5 - Update copyright dates - Fix INI parser to include top-level values with no section header +- Fix INI and Key/Value parsers to only remove one quotation mark from the + beginning and end of values. 20221230 v1.22.4 - Add `iwconfig` command parser diff --git a/jc/parsers/ini.py b/jc/parsers/ini.py index 96dce33a..e81e4e30 100644 --- a/jc/parsers/ini.py +++ b/jc/parsers/ini.py @@ -107,10 +107,10 @@ def _process(proc_data): for heading in proc_data: for key, value in proc_data[heading].items(): if value is not None and value.startswith('"') and value.endswith('"'): - proc_data[heading][key] = value.lstrip('"').rstrip('"') + proc_data[heading][key] = value[1:-1] elif value is not None and value.startswith("'") and value.endswith("'"): - proc_data[heading][key] = value.lstrip("'").rstrip("'") + proc_data[heading][key] = value[1:-1] elif value is None: proc_data[heading][key] = '' diff --git a/jc/parsers/kv.py b/jc/parsers/kv.py index 0cc47c69..de1b4421 100644 --- a/jc/parsers/kv.py +++ b/jc/parsers/kv.py @@ -83,10 +83,10 @@ 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].lstrip('"').rstrip('"') + 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].lstrip("'").rstrip("'") + proc_data[key] = proc_data[key][1:-1] elif proc_data[key] is None: proc_data[key] = ''