1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-09 01:05:53 +02:00

fix kv and ini parsers to only remove 1 quote from beginning and end

This commit is contained in:
Kelly Brazil
2023-01-03 13:26:52 -08:00
parent b0756fa0f9
commit c94f5d83fa
3 changed files with 6 additions and 4 deletions

View File

@ -3,6 +3,8 @@ jc changelog
20230103 v1.22.5 20230103 v1.22.5
- Update copyright dates - Update copyright dates
- Fix INI parser to include top-level values with no section header - 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 20221230 v1.22.4
- Add `iwconfig` command parser - Add `iwconfig` command parser

View File

@ -107,10 +107,10 @@ def _process(proc_data):
for heading in proc_data: for heading in proc_data:
for key, value in proc_data[heading].items(): for key, value in proc_data[heading].items():
if value is not None and value.startswith('"') and value.endswith('"'): 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("'"): 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: elif value is None:
proc_data[heading][key] = '' proc_data[heading][key] = ''

View File

@ -83,10 +83,10 @@ def _process(proc_data):
# remove quotation marks from beginning and end of values # remove quotation marks from beginning and end of values
for key in proc_data: for key in proc_data:
if proc_data[key] is not None and proc_data[key].startswith('"') and proc_data[key].endswith('"'): 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("'"): 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: elif proc_data[key] is None:
proc_data[key] = '' proc_data[key] = ''