mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
working configuration_descriptor and device_descriptor attributes
This commit is contained in:
@ -29,19 +29,25 @@ Schema:
|
|||||||
"device_descriptor": {
|
"device_descriptor": {
|
||||||
"<attribute>": {
|
"<attribute>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string
|
"description": string,
|
||||||
|
"attributes": [
|
||||||
|
string
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"configuration_descriptor": {
|
"configuration_descriptor": {
|
||||||
"<attribute>": {
|
"<attribute>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string
|
"description": string,
|
||||||
|
"attributes": [
|
||||||
|
string
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"interface_association": {
|
"interface_association": {
|
||||||
"<attribute>": {
|
"<attribute>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"attributes": [
|
"attributes": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -449,12 +455,34 @@ class _LsUsb():
|
|||||||
for dd in self.device_descriptor_list:
|
for dd in self.device_descriptor_list:
|
||||||
keyname = tuple(dd.keys())[0]
|
keyname = tuple(dd.keys())[0]
|
||||||
if '_state' in dd[keyname] and dd[keyname]['_state']['bus_idx'] == idx:
|
if '_state' in dd[keyname] and dd[keyname]['_state']['bus_idx'] == idx:
|
||||||
|
|
||||||
|
# is this a top level value or an attribute?
|
||||||
|
if dd[keyname]['_state']['attribute_value']:
|
||||||
|
last_attr = dd[keyname]['_state']['last_attribute']
|
||||||
|
if 'attributes' not in self.output_line['device_descriptor'][last_attr]:
|
||||||
|
self.output_line['device_descriptor'][last_attr]['attributes'] = []
|
||||||
|
|
||||||
|
i_desc_obj_attribute = f'{keyname} {dd[keyname].get("value", "")} {dd[keyname].get("description", "")}'.strip()
|
||||||
|
self.output_line['device_descriptor'][last_attr]['attributes'].append(i_desc_obj_attribute)
|
||||||
|
continue
|
||||||
|
|
||||||
self.output_line['device_descriptor'].update(dd)
|
self.output_line['device_descriptor'].update(dd)
|
||||||
del self.output_line['device_descriptor'][keyname]['_state']
|
del self.output_line['device_descriptor'][keyname]['_state']
|
||||||
|
|
||||||
for cd in self.configuration_descriptor_list:
|
for cd in self.configuration_descriptor_list:
|
||||||
keyname = tuple(cd.keys())[0]
|
keyname = tuple(cd.keys())[0]
|
||||||
if '_state' in cd[keyname] and cd[keyname]['_state']['bus_idx'] == idx:
|
if '_state' in cd[keyname] and cd[keyname]['_state']['bus_idx'] == idx:
|
||||||
|
|
||||||
|
# is this a top level value or an attribute?
|
||||||
|
if cd[keyname]['_state']['attribute_value']:
|
||||||
|
last_attr = cd[keyname]['_state']['last_attribute']
|
||||||
|
if 'attributes' not in self.output_line['device_descriptor']['configuration_descriptor'][last_attr]:
|
||||||
|
self.output_line['device_descriptor']['configuration_descriptor'][last_attr]['attributes'] = []
|
||||||
|
|
||||||
|
i_desc_obj_attribute = f'{keyname} {cd[keyname].get("value", "")} {cd[keyname].get("description", "")}'.strip()
|
||||||
|
self.output_line['device_descriptor']['configuration_descriptor'][last_attr]['attributes'].append(i_desc_obj_attribute)
|
||||||
|
continue
|
||||||
|
|
||||||
self.output_line['device_descriptor']['configuration_descriptor'].update(cd)
|
self.output_line['device_descriptor']['configuration_descriptor'].update(cd)
|
||||||
del self.output_line['device_descriptor']['configuration_descriptor'][keyname]['_state']
|
del self.output_line['device_descriptor']['configuration_descriptor'][keyname]['_state']
|
||||||
|
|
||||||
@ -465,8 +493,8 @@ class _LsUsb():
|
|||||||
# is this a top level value or an attribute?
|
# is this a top level value or an attribute?
|
||||||
if ia[keyname]['_state']['attribute_value']:
|
if ia[keyname]['_state']['attribute_value']:
|
||||||
last_attr = ia[keyname]['_state']['last_attribute']
|
last_attr = ia[keyname]['_state']['last_attribute']
|
||||||
if 'attributes' not in i_desc_obj[last_attr]:
|
if 'attributes' not in self.output_line['device_descriptor']['configuration_descriptor']['interface_association'][last_attr]:
|
||||||
i_desc_obj[last_attr]['attributes'] = []
|
self.output_line['device_descriptor']['configuration_descriptor']['interface_association'][last_attr]['attributes'] = []
|
||||||
|
|
||||||
i_desc_obj_attribute = f'{keyname} {ia[keyname].get("value", "")} {ia[keyname].get("description", "")}'.strip()
|
i_desc_obj_attribute = f'{keyname} {ia[keyname].get("value", "")} {ia[keyname].get("description", "")}'.strip()
|
||||||
self.output_line['device_descriptor']['configuration_descriptor']['interface_association'][last_attr]['attributes'].append(i_desc_obj_attribute)
|
self.output_line['device_descriptor']['configuration_descriptor']['interface_association'][last_attr]['attributes'].append(i_desc_obj_attribute)
|
||||||
|
Reference in New Issue
Block a user