mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
use jc.utils type checks
This commit is contained in:
@ -95,9 +95,8 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
||||
|
||||
Iterator object
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not hasattr(data, '__iter__') or isinstance(data, (str, bytes)):
|
||||
raise TypeError("Input data must be a non-string iterable object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.streaming_input_type_check(data)
|
||||
|
||||
# convert data to an iterable in case a sequence like a list is used as input.
|
||||
# this allows the exhaustion of the input so we don't double-process later.
|
||||
|
@ -97,14 +97,13 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
||||
|
||||
Iterator object
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not hasattr(data, '__iter__') or isinstance(data, (str, bytes)):
|
||||
raise TypeError("Input data must be a non-string iterable object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.streaming_input_type_check(data)
|
||||
|
||||
for line in data:
|
||||
output_line = {}
|
||||
try:
|
||||
if not isinstance(line, str): raise TypeError("Input line must be a 'str' object.")
|
||||
jc.utils.streaming_line_input_type_check(line)
|
||||
|
||||
#
|
||||
# parse the input here
|
||||
|
@ -123,15 +123,14 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
||||
|
||||
Iterator object
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not hasattr(data, '__iter__') or isinstance(data, (str, bytes)):
|
||||
raise TypeError("Input data must be a non-string iterable object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.streaming_input_type_check(data)
|
||||
|
||||
parent = ''
|
||||
|
||||
for line in data:
|
||||
try:
|
||||
if not isinstance(line, str): raise TypeError("Input line must be a 'str' object.")
|
||||
jc.utils.streaming_line_input_type_check(line)
|
||||
|
||||
# skip line if it starts with 'total 1234'
|
||||
if re.match(r'total [0-9]+', line):
|
||||
|
@ -468,14 +468,13 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
||||
"""
|
||||
s = _state()
|
||||
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not hasattr(data, '__iter__') or isinstance(data, (str, bytes)):
|
||||
raise TypeError("Input data must be a non-string iterable object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.streaming_input_type_check(data)
|
||||
|
||||
for line in data:
|
||||
output_line = {}
|
||||
try:
|
||||
if not isinstance(line, str): raise TypeError("Input line must be a 'str' object.")
|
||||
jc.utils.streaming_line_input_type_check(line)
|
||||
|
||||
# skip blank lines
|
||||
if line.strip() == '':
|
||||
|
@ -145,9 +145,8 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
||||
|
||||
Iterator object
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not hasattr(data, '__iter__') or isinstance(data, (str, bytes)):
|
||||
raise TypeError("Input data must be a non-string iterable object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.streaming_input_type_check(data)
|
||||
|
||||
procs = None
|
||||
buff_cache = None
|
||||
@ -158,7 +157,7 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
||||
for line in data:
|
||||
output_line = {}
|
||||
try:
|
||||
if not isinstance(line, str): raise TypeError("Input line must be a 'str' object.")
|
||||
jc.utils.streaming_line_input_type_check(line)
|
||||
|
||||
# skip blank lines
|
||||
if line.strip() == '':
|
||||
|
Reference in New Issue
Block a user