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

add int/float conversions

This commit is contained in:
Kelly Brazil
2022-01-28 15:00:05 -08:00
parent 38f04b1c96
commit d6de81747f

View File

@ -25,7 +25,7 @@ Schema:
[ [
{ {
"type": string, # 'file' or 'summary' "type": string, # 'item' or 'summary'
"filename": string, "filename": string,
"metadata": string, "metadata": string,
"update_type": string/null, "update_type": string/null,
@ -85,7 +85,15 @@ def _process(proc_data: List[Dict]) -> List[Dict]:
List of Dictionaries. Structured to conform to the schema. List of Dictionaries. Structured to conform to the schema.
""" """
# no further processing needed int_list = ['sent', 'received', 'total_size']
float_list = ['bytes_sec', 'speedup']
for entry in proc_data:
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
if key in float_list:
entry[key] = jc.utils.convert_to_float(entry[key])
return proc_data return proc_data
@ -200,7 +208,7 @@ def parse(
filename = file_line.group('name') filename = file_line.group('name')
output_line = { output_line = {
'type': 'file', 'type': 'item',
'filename': filename, 'filename': filename,
'metadata': meta, 'metadata': meta,
'update_type': update_type[meta[0]], 'update_type': update_type[meta[0]],