From 5e7f302a9c45343c36e81944db38a435e6c8a20c Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Sun, 12 Sep 2021 16:35:46 -0700 Subject: [PATCH] Raise exceptions unless the -q or quiet flag are used --- jc/parsers/ls_s.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/jc/parsers/ls_s.py b/jc/parsers/ls_s.py index 0f1f193a..c935e97f 100644 --- a/jc/parsers/ls_s.py +++ b/jc/parsers/ls_s.py @@ -70,7 +70,6 @@ class info(): # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] - # magic_commands = ['ls', 'vdir'] streaming = True @@ -172,7 +171,7 @@ def parse(data, raw=False, quiet=False): # Only support -l option if not re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', line): - raise ParseError + raise ParseError(f'Unparsable line: {line[0:60]}') # split filenames and links if len(parsed_line) == 9: @@ -204,11 +203,14 @@ def parse(data, raw=False, quiet=False): yield _process(output_line) except Exception: - yield { - '_meta': - { - 'success': False, - 'error': 'error parsing line', - 'line': line.strip() - } - } + if not quiet: + raise + else: + yield { + '_meta': + { + 'success': False, + 'error': 'error parsing line', + 'line': line.strip() + } + }