mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-23 00:29:59 +02:00
working history list
This commit is contained in:
@ -92,6 +92,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
device_name = None
|
device_name = None
|
||||||
detail_obj = {}
|
detail_obj = {}
|
||||||
detail_key = ''
|
detail_key = ''
|
||||||
|
history_list = []
|
||||||
|
history_list_obj = {}
|
||||||
|
|
||||||
if jc.utils.has_data(data):
|
if jc.utils.has_data(data):
|
||||||
|
|
||||||
@ -119,7 +121,14 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
# history detail lines
|
# history detail lines
|
||||||
if line.startswith(' ') and ':' not in line:
|
if line.startswith(' ') and ':' not in line:
|
||||||
device_obj[detail_key] = 'history detail line'
|
line_list = line.strip().split()
|
||||||
|
history_list_obj = {
|
||||||
|
'time': line_list[0],
|
||||||
|
'percent_charged': line_list[1],
|
||||||
|
'status': line_list[2]
|
||||||
|
}
|
||||||
|
history_list.append(history_list_obj)
|
||||||
|
device_obj[detail_key] = history_list
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# general detail lines
|
# general detail lines
|
||||||
@ -134,6 +143,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if line.startswith(' ') and ':' in line and line.strip().split(':', maxsplit=1)[1] == '':
|
if line.startswith(' ') and ':' in line and line.strip().split(':', maxsplit=1)[1] == '':
|
||||||
detail_key = line.strip().lower().replace('-', '_').replace(' ', '_').replace('(', '').replace(')', '').rstrip(':')
|
detail_key = line.strip().lower().replace('-', '_').replace(' ', '_').replace('(', '').replace(')', '').rstrip(':')
|
||||||
device_obj[detail_key] = {}
|
device_obj[detail_key] = {}
|
||||||
|
history_list = []
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# top level lines
|
# top level lines
|
||||||
|
Reference in New Issue
Block a user