diff --git a/jc/parsers/foo_s.py b/jc/parsers/foo_s.py index 44338639..80692a70 100644 --- a/jc/parsers/foo_s.py +++ b/jc/parsers/foo_s.py @@ -120,10 +120,9 @@ def parse( """ jc.utils.compatibility(__name__, info.compatible, quiet) jc.utils.streaming_input_type_check(data) - line = '' - try: - for line in data: + for line in data: + try: output_line: Dict = {} jc.utils.streaming_line_input_type_check(line) @@ -136,9 +135,9 @@ def parse( else: raise ParseError('Not foo data') - except Exception as e: - if not ignore_exceptions: - e.args = (str(e) + ignore_exceptions_msg,) - raise e + except Exception as e: + if not ignore_exceptions: + e.args = (str(e) + ignore_exceptions_msg,) + raise e - yield e, line + yield e, line diff --git a/jc/parsers/iostat_s.py b/jc/parsers/iostat_s.py index d5d6f00e..e0097d01 100644 --- a/jc/parsers/iostat_s.py +++ b/jc/parsers/iostat_s.py @@ -189,10 +189,9 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False): headers = '' cpu_list = [] device_list = [] - line = '' - try: - for line in data: + for line in data: + try: jc.utils.streaming_line_input_type_check(line) output_line = {} @@ -231,9 +230,9 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False): else: raise ParseError('Not iostat data') - except Exception as e: - if not ignore_exceptions: - e.args = (str(e) + ignore_exceptions_msg,) - raise e + except Exception as e: + if not ignore_exceptions: + e.args = (str(e) + ignore_exceptions_msg,) + raise e - yield e, line + yield e, line diff --git a/jc/parsers/ls_s.py b/jc/parsers/ls_s.py index a28c68a0..a8b17a9c 100644 --- a/jc/parsers/ls_s.py +++ b/jc/parsers/ls_s.py @@ -149,10 +149,9 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False): jc.utils.streaming_input_type_check(data) parent = '' - line = '' - try: - for line in data: + for line in data: + try: jc.utils.streaming_line_input_type_check(line) # skip line if it starts with 'total 1234' @@ -165,7 +164,7 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False): # Look for parent line if glob or -R is used if not re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', line) \ - and line.strip().endswith(':'): + and line.strip().endswith(':'): parent = line.strip()[:-1] continue @@ -200,9 +199,9 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False): yield output_line if raw else _process(output_line) - except Exception as e: - if not ignore_exceptions: - e.args = (str(e) + ignore_exceptions_msg,) - raise e + except Exception as e: + if not ignore_exceptions: + e.args = (str(e) + ignore_exceptions_msg,) + raise e - yield e, line + yield e, line diff --git a/jc/parsers/ping_s.py b/jc/parsers/ping_s.py index 4779ee8f..2639054b 100644 --- a/jc/parsers/ping_s.py +++ b/jc/parsers/ping_s.py @@ -491,14 +491,13 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False): Iterator object """ - s = _state() - line = '' - jc.utils.compatibility(__name__, info.compatible, quiet) jc.utils.streaming_input_type_check(data) - try: - for line in data: + s = _state() + + for line in data: + try: output_line = {} jc.utils.streaming_line_input_type_check(line) @@ -548,9 +547,9 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False): else: continue - except Exception as e: - if not ignore_exceptions: - e.args = (str(e) + ignore_exceptions_msg,) - raise e + except Exception as e: + if not ignore_exceptions: + e.args = (str(e) + ignore_exceptions_msg,) + raise e - yield e, line + yield e, line diff --git a/jc/parsers/rsync_s.py b/jc/parsers/rsync_s.py index 625fcb08..560b34cf 100644 --- a/jc/parsers/rsync_s.py +++ b/jc/parsers/rsync_s.py @@ -173,7 +173,6 @@ def parse( summary: Dict = {} process: str = '' last_process: str = '' - line: str = '' update_type = { '<': 'file sent', @@ -271,8 +270,8 @@ def parse( stat2_line_log_v_re = re.compile(r'(?P\d\d\d\d/\d\d/\d\d)\s+(?P