mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-23 00:29:59 +02:00
integer conversions
This commit is contained in:
@ -46,7 +46,9 @@ Examples:
|
|||||||
### parse
|
### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
def parse(data: str,
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False) -> List[JSONDictType]
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
@ -38,6 +38,7 @@ Examples:
|
|||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
from typing import List, Dict
|
from typing import List, Dict
|
||||||
|
from jc.jc_types import JSONDictType
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def _process(proc_data: List[Dict]) -> List[Dict]:
|
def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]:
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -66,14 +67,29 @@ 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.
|
||||||
"""
|
"""
|
||||||
return proc_data
|
int_list: set[str] = {
|
||||||
|
'domain', 'bus', 'dev', 'function', 'class_id', 'vendor_id', 'device_id',
|
||||||
|
'svendor_id', 'sdevice_id', 'physlot', 'progif'
|
||||||
|
}
|
||||||
|
|
||||||
|
new_list: List[JSONDictType] = []
|
||||||
|
|
||||||
|
for item in proc_data:
|
||||||
|
output: Dict = {}
|
||||||
|
for key, val in item.items():
|
||||||
|
output[key] = val
|
||||||
|
if key in int_list:
|
||||||
|
output[key + '_int'] = int(val, 16) # type: ignore
|
||||||
|
new_list.append(output)
|
||||||
|
|
||||||
|
return new_list
|
||||||
|
|
||||||
|
|
||||||
def parse(
|
def parse(
|
||||||
data: str,
|
data: str,
|
||||||
raw: bool = False,
|
raw: bool = False,
|
||||||
quiet: bool = False
|
quiet: bool = False
|
||||||
) -> List[Dict]:
|
) -> List[JSONDictType]:
|
||||||
"""
|
"""
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
@ -111,7 +127,7 @@ def parse(
|
|||||||
if domain:
|
if domain:
|
||||||
dom = domain[0]
|
dom = domain[0]
|
||||||
else:
|
else:
|
||||||
dom = None
|
dom = "00"
|
||||||
|
|
||||||
dev, fun = dev_fun.split('.')
|
dev, fun = dev_fun.split('.')
|
||||||
device_output['domain'] = dom
|
device_output['domain'] = dom
|
||||||
|
Reference in New Issue
Block a user