mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
Don't get too fancy with dict type annotations
This commit is contained in:
@ -44,6 +44,7 @@ else:
|
||||
ParserInfoType = Dict
|
||||
TimeStampFormatType = Dict
|
||||
|
||||
|
||||
AboutJCType = Dict[str, Union[str, int, List[ParserInfoType]]]
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ Examples:
|
||||
$ foo | jc --foo -p -r
|
||||
[]
|
||||
"""
|
||||
from typing import List
|
||||
from typing import List, Dict
|
||||
from jc.jc_types import JSONDictType
|
||||
import jc.utils
|
||||
|
||||
@ -96,7 +96,7 @@ def parse(
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output: List[JSONDictType] = []
|
||||
raw_output: List[Dict] = []
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
|
@ -40,7 +40,7 @@ Examples:
|
||||
{example output}
|
||||
...
|
||||
"""
|
||||
from typing import Iterable
|
||||
from typing import Dict, Iterable
|
||||
import jc.utils
|
||||
from jc.streaming import (
|
||||
add_jc_meta, streaming_input_type_check, streaming_line_input_type_check, raise_or_yield
|
||||
@ -115,7 +115,7 @@ def parse(
|
||||
for line in data:
|
||||
try:
|
||||
streaming_line_input_type_check(line)
|
||||
output_line: JSONDictType = {}
|
||||
output_line: Dict = {}
|
||||
|
||||
# parse the content here
|
||||
# check out helper functions in jc.utils
|
||||
|
@ -32,7 +32,8 @@ Examples:
|
||||
[]
|
||||
"""
|
||||
import re
|
||||
from typing import List, Dict
|
||||
from typing import Dict
|
||||
from jc.jc_types import JSONDictType
|
||||
import jc.utils
|
||||
|
||||
|
||||
@ -48,7 +49,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def _process(proc_data: Dict) -> Dict:
|
||||
def _process(proc_data: JSONDictType) -> JSONDictType:
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -67,7 +68,7 @@ def parse(
|
||||
data: str,
|
||||
raw: bool = False,
|
||||
quiet: bool = False
|
||||
) -> Dict:
|
||||
) -> JSONDictType:
|
||||
"""
|
||||
Main text parsing function
|
||||
|
||||
|
@ -77,7 +77,7 @@ import jc.utils
|
||||
from jc.streaming import (
|
||||
add_jc_meta, streaming_input_type_check, streaming_line_input_type_check, raise_or_yield
|
||||
)
|
||||
from typing import Iterable
|
||||
from typing import Dict, Iterable
|
||||
from jc.jc_types import JSONDictType, StreamingOutputType
|
||||
from jc.exceptions import ParseError
|
||||
|
||||
@ -156,7 +156,7 @@ def parse(
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
streaming_input_type_check(data)
|
||||
|
||||
output_line: JSONDictType = {}
|
||||
output_line: Dict = {}
|
||||
os_type = ''
|
||||
|
||||
for line in data:
|
||||
@ -184,16 +184,14 @@ def parse(
|
||||
output_line['file'] = line_list[1]
|
||||
|
||||
# populate link_to field if -> found
|
||||
file_string = output_line['file']
|
||||
if isinstance(file_string, str):
|
||||
if ' -> ' in file_string:
|
||||
filename = file_string.split(' -> ')[0].strip('\u2018').rstrip('\u2019')
|
||||
link = file_string.split(' -> ')[1].strip('\u2018').rstrip('\u2019')
|
||||
output_line['file'] = filename
|
||||
output_line['link_to'] = link
|
||||
else:
|
||||
filename = file_string.split(' -> ')[0].strip('\u2018').rstrip('\u2019')
|
||||
output_line['file'] = filename
|
||||
if ' -> ' in output_line['file']:
|
||||
filename = output_line['file'].split(' -> ')[0].strip('\u2018').rstrip('\u2019')
|
||||
link = output_line['file'].split(' -> ')[1].strip('\u2018').rstrip('\u2019')
|
||||
output_line['file'] = filename
|
||||
output_line['link_to'] = link
|
||||
else:
|
||||
filename = output_line['file'].split(' -> ')[0].strip('\u2018').rstrip('\u2019')
|
||||
output_line['file'] = filename
|
||||
|
||||
continue
|
||||
|
||||
|
Reference in New Issue
Block a user