mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
use new streaming functions
This commit is contained in:
@ -87,7 +87,9 @@ import string
|
|||||||
import ipaddress
|
import ipaddress
|
||||||
import jc.utils
|
import jc.utils
|
||||||
from jc.exceptions import ParseError
|
from jc.exceptions import ParseError
|
||||||
from jc.utils import ignore_exceptions_msg, add_jc_meta
|
from jc.streaming import (
|
||||||
|
add_jc_meta, streaming_input_type_check, streaming_line_input_type_check, raise_or_yield
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
@ -492,14 +494,14 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
|||||||
Iterator object
|
Iterator object
|
||||||
"""
|
"""
|
||||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
jc.utils.streaming_input_type_check(data)
|
streaming_input_type_check(data)
|
||||||
|
|
||||||
s = _state()
|
s = _state()
|
||||||
|
|
||||||
for line in data:
|
for line in data:
|
||||||
try:
|
try:
|
||||||
output_line = {}
|
output_line = {}
|
||||||
jc.utils.streaming_line_input_type_check(line)
|
streaming_line_input_type_check(line)
|
||||||
|
|
||||||
# skip blank lines
|
# skip blank lines
|
||||||
if line.strip() == '':
|
if line.strip() == '':
|
||||||
@ -548,8 +550,4 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if not ignore_exceptions:
|
yield raise_or_yield(ignore_exceptions, e, line)
|
||||||
e.args = (str(e) + ignore_exceptions_msg,)
|
|
||||||
raise e
|
|
||||||
|
|
||||||
yield e, line
|
|
||||||
|
Reference in New Issue
Block a user