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

formatting

This commit is contained in:
Kelly Brazil
2021-03-26 14:55:47 -07:00
parent 26ef298437
commit e7751322ea

View File

@ -149,7 +149,7 @@ def process(proc_data):
"""
# convert ints and floats for top-level keys
for item in proc_data:
for item in proc_data:
for key in item:
try:
item[key] = int(item[key])
@ -163,21 +163,22 @@ def process(proc_data):
new_list = []
for list_item in item[key]:
try:
new_list.append(int(list_item))
new_list.append(int(list_item))
except (Exception):
try:
new_list.append(float(list_item))
new_list.append(float(list_item))
except (Exception):
pass
item[key] = new_list
return proc_data
def post_parse(data):
# remove empty items
cleandata = []
for ssid in data:
ssid = { k : v for k, v in ssid.items() if v}
ssid = {k: v for k, v in ssid.items() if v}
cleandata.append(ssid)
# remove asterisks from begining of values
@ -277,6 +278,7 @@ def post_parse(data):
return process(cleandata)
def parse(data, raw=False, quiet=False):
"""
Main text parsing function