1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

simplify debug option

This commit is contained in:
Kelly Brazil
2020-06-30 11:26:09 -07:00
parent 18bb779ee5
commit c1ac183a04

View File

@ -387,21 +387,6 @@ def main():
found = False found = False
if debug:
if verbose_debug:
import cgitb
cgitb.enable(display=1, logdir=None, context=5, format="text")
for arg in sys.argv:
parser_name = parser_shortname(arg)
if parser_name in parsers:
# load parser module just in time so we don't need to load all modules
parser = parser_module(arg)
result = parser.parse(data, raw=raw, quiet=quiet)
found = True
break
else:
for arg in sys.argv: for arg in sys.argv:
parser_name = parser_shortname(arg) parser_name = parser_shortname(arg)
@ -412,7 +397,15 @@ def main():
result = parser.parse(data, raw=raw, quiet=quiet) result = parser.parse(data, raw=raw, quiet=quiet)
found = True found = True
break break
except Exception: except Exception:
if verbose_debug:
import cgitb
cgitb.enable(display=1, logdir=None, context=5, format="text")
if debug:
raise
else:
jc.utils.error_message( jc.utils.error_message(
f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n For details use the -d option.') f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n For details use the -d option.')
sys.exit(1) sys.exit(1)