mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
remove unneeded type ignore comments
This commit is contained in:
@ -211,7 +211,7 @@ def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]:
|
|||||||
|
|
||||||
# add unix timestamps
|
# add unix timestamps
|
||||||
if 'date' in log:
|
if 'date' in log:
|
||||||
ts = jc.utils.timestamp(log['date'], format_hint=(1800,)) # type: ignore
|
ts = jc.utils.timestamp(log['date'], format_hint=(1800,))
|
||||||
log['epoch'] = ts.naive
|
log['epoch'] = ts.naive
|
||||||
log['epoch_utc'] = ts.utc
|
log['epoch_utc'] = ts.utc
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ def _process(proc_data: JSONDictType) -> JSONDictType:
|
|||||||
|
|
||||||
# add unix timestamps
|
# add unix timestamps
|
||||||
if 'date' in proc_data:
|
if 'date' in proc_data:
|
||||||
ts = jc.utils.timestamp(proc_data['date'], format_hint=(1800,)) # type: ignore
|
ts = jc.utils.timestamp(proc_data['date'], format_hint=(1800,))
|
||||||
proc_data['epoch'] = ts.naive
|
proc_data['epoch'] = ts.naive
|
||||||
proc_data['epoch_utc'] = ts.utc
|
proc_data['epoch_utc'] = ts.utc
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]:
|
|||||||
kv_options = {}
|
kv_options = {}
|
||||||
|
|
||||||
if 'options' in item:
|
if 'options' in item:
|
||||||
opt_list = item['options'].split(',') # type: ignore
|
opt_list = item['options'].split(',')
|
||||||
|
|
||||||
for option in opt_list:
|
for option in opt_list:
|
||||||
if '=' in option:
|
if '=' in option:
|
||||||
|
@ -59,7 +59,7 @@ Examples:
|
|||||||
...
|
...
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
from typing import List, Dict
|
from typing import List, Union
|
||||||
from jc.jc_types import JSONDictType
|
from jc.jc_types import JSONDictType
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ def _process(proc_data: List[JSONDictType]) -> JSONDictType:
|
|||||||
for item in proc_data:
|
for item in proc_data:
|
||||||
new_dict.update(
|
new_dict.update(
|
||||||
{
|
{
|
||||||
item['reference']: item['commit'] # type: ignore
|
item['reference']: item['commit']
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ def parse(
|
|||||||
data: str,
|
data: str,
|
||||||
raw: bool = False,
|
raw: bool = False,
|
||||||
quiet: bool = False
|
quiet: bool = False
|
||||||
) -> List[JSONDictType]:
|
) -> Union[JSONDictType, List[JSONDictType]]:
|
||||||
"""
|
"""
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
@ -122,7 +122,8 @@ def parse(
|
|||||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
jc.utils.input_type_check(data)
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output: List[Dict] = []
|
raw_output: List[JSONDictType] = []
|
||||||
|
output_line: JSONDictType = {}
|
||||||
|
|
||||||
if jc.utils.has_data(data):
|
if jc.utils.has_data(data):
|
||||||
|
|
||||||
@ -135,4 +136,4 @@ def parse(
|
|||||||
}
|
}
|
||||||
raw_output.append(output_line)
|
raw_output.append(output_line)
|
||||||
|
|
||||||
return raw_output if raw else _process(raw_output) # type: ignore
|
return raw_output if raw else _process(raw_output)
|
||||||
|
@ -158,7 +158,7 @@ def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]:
|
|||||||
for key, val in item.items():
|
for key, val in item.items():
|
||||||
output[key] = val
|
output[key] = val
|
||||||
if key in int_list:
|
if key in int_list:
|
||||||
output[key + '_int'] = int(val, 16) # type: ignore
|
output[key + '_int'] = int(val, 16)
|
||||||
new_list.append(output)
|
new_list.append(output)
|
||||||
|
|
||||||
return new_list
|
return new_list
|
||||||
|
@ -66,8 +66,8 @@ def _process(proc_data: JSONDictType) -> JSONDictType:
|
|||||||
Dictionary. Structured to conform to the schema.
|
Dictionary. Structured to conform to the schema.
|
||||||
"""
|
"""
|
||||||
# check for EFI partition@boot-manager and split/add fields
|
# check for EFI partition@boot-manager and split/add fields
|
||||||
if 'partition' in proc_data and '@' in proc_data['partition']: # type: ignore
|
if 'partition' in proc_data and '@' in proc_data['partition']:
|
||||||
new_part, efi_bootmgr = proc_data['partition'].split('@', maxsplit=1) # type: ignore
|
new_part, efi_bootmgr = proc_data['partition'].split('@', maxsplit=1)
|
||||||
proc_data['partition'] = new_part
|
proc_data['partition'] = new_part
|
||||||
proc_data['efi_bootmgr'] = efi_bootmgr
|
proc_data['efi_bootmgr'] = efi_bootmgr
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ def _process(proc_data: JSONDictType) -> JSONDictType:
|
|||||||
|
|
||||||
for item in int_list:
|
for item in int_list:
|
||||||
if item in proc_data:
|
if item in proc_data:
|
||||||
proc_data[item] = int(proc_data[item]) # type: ignore
|
proc_data[item] = int(proc_data[item])
|
||||||
|
|
||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ def _process(proc_data: JSONDictType) -> JSONDictType:
|
|||||||
# this is a list value
|
# this is a list value
|
||||||
if key == 'acceptenv':
|
if key == 'acceptenv':
|
||||||
new_list: List[str] = []
|
new_list: List[str] = []
|
||||||
for item in val: # type: ignore
|
for item in val:
|
||||||
new_list.extend(item.split())
|
new_list.extend(item.split())
|
||||||
proc_data[key] = new_list
|
proc_data[key] = new_list
|
||||||
continue
|
continue
|
||||||
@ -534,13 +534,13 @@ def _process(proc_data: JSONDictType) -> JSONDictType:
|
|||||||
# this is a list value
|
# this is a list value
|
||||||
if key == 'include':
|
if key == 'include':
|
||||||
new_list = []
|
new_list = []
|
||||||
for item in val: # type: ignore
|
for item in val:
|
||||||
new_list.extend(item.split())
|
new_list.extend(item.split())
|
||||||
proc_data[key] = new_list
|
proc_data[key] = new_list
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if key == 'maxstartups':
|
if key == 'maxstartups':
|
||||||
maxstart_split = val.split(':', maxsplit=2) # type: ignore
|
maxstart_split = val.split(':', maxsplit=2)
|
||||||
proc_data[key] = maxstart_split[0]
|
proc_data[key] = maxstart_split[0]
|
||||||
if len(maxstart_split) > 1:
|
if len(maxstart_split) > 1:
|
||||||
proc_data[key + '_rate'] = maxstart_split[1]
|
proc_data[key + '_rate'] = maxstart_split[1]
|
||||||
@ -550,31 +550,31 @@ def _process(proc_data: JSONDictType) -> JSONDictType:
|
|||||||
|
|
||||||
if key == 'port':
|
if key == 'port':
|
||||||
port_list: List[int] = []
|
port_list: List[int] = []
|
||||||
for item in val: # type: ignore
|
for item in val:
|
||||||
port_list.append(int(item))
|
port_list.append(int(item))
|
||||||
proc_data[key] = port_list
|
proc_data[key] = port_list
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if key == 'rekeylimit':
|
if key == 'rekeylimit':
|
||||||
rekey_split = val.split(maxsplit=1) # type: ignore
|
rekey_split = val.split(maxsplit=1)
|
||||||
proc_data[key] = rekey_split[0]
|
proc_data[key] = rekey_split[0]
|
||||||
if len(rekey_split) > 1:
|
if len(rekey_split) > 1:
|
||||||
proc_data[key + '_time'] = rekey_split[1]
|
proc_data[key + '_time'] = rekey_split[1]
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if key == 'subsystem':
|
if key == 'subsystem':
|
||||||
sub_split = val.split(maxsplit=1) # type: ignore
|
sub_split = val.split(maxsplit=1)
|
||||||
proc_data[key] = sub_split[0]
|
proc_data[key] = sub_split[0]
|
||||||
if len(sub_split) > 1:
|
if len(sub_split) > 1:
|
||||||
proc_data[key + '_command'] = sub_split[1]
|
proc_data[key + '_command'] = sub_split[1]
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if key in split_fields_space:
|
if key in split_fields_space:
|
||||||
proc_data[key] = val.split() # type: ignore
|
proc_data[key] = val.split()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if key in split_fields_comma:
|
if key in split_fields_comma:
|
||||||
proc_data[key] = val.split(',') # type: ignore
|
proc_data[key] = val.split(',')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for key, val in proc_data.items():
|
for key, val in proc_data.items():
|
||||||
|
@ -143,7 +143,7 @@ def _process(proc_data: JSONDictType) -> JSONDictType:
|
|||||||
List of Dictionaries. Structured to conform to the schema.
|
List of Dictionaries. Structured to conform to the schema.
|
||||||
"""
|
"""
|
||||||
if 'L' in proc_data:
|
if 'L' in proc_data:
|
||||||
proc_data['L'] = int(proc_data['L']) # type: ignore
|
proc_data['L'] = int(proc_data['L'])
|
||||||
|
|
||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user