mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
formatting
This commit is contained in:
@ -149,7 +149,7 @@ def process(proc_data):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# convert ints and floats for top-level keys
|
# convert ints and floats for top-level keys
|
||||||
for item in proc_data:
|
for item in proc_data:
|
||||||
for key in item:
|
for key in item:
|
||||||
try:
|
try:
|
||||||
item[key] = int(item[key])
|
item[key] = int(item[key])
|
||||||
@ -163,21 +163,22 @@ def process(proc_data):
|
|||||||
new_list = []
|
new_list = []
|
||||||
for list_item in item[key]:
|
for list_item in item[key]:
|
||||||
try:
|
try:
|
||||||
new_list.append(int(list_item))
|
new_list.append(int(list_item))
|
||||||
except (Exception):
|
except (Exception):
|
||||||
try:
|
try:
|
||||||
new_list.append(float(list_item))
|
new_list.append(float(list_item))
|
||||||
except (Exception):
|
except (Exception):
|
||||||
pass
|
pass
|
||||||
item[key] = new_list
|
item[key] = new_list
|
||||||
|
|
||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
def post_parse(data):
|
def post_parse(data):
|
||||||
# remove empty items
|
# remove empty items
|
||||||
cleandata = []
|
cleandata = []
|
||||||
for ssid in data:
|
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)
|
cleandata.append(ssid)
|
||||||
|
|
||||||
# remove asterisks from begining of values
|
# remove asterisks from begining of values
|
||||||
@ -277,6 +278,7 @@ def post_parse(data):
|
|||||||
|
|
||||||
return process(cleandata)
|
return process(cleandata)
|
||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
"""
|
"""
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
Reference in New Issue
Block a user