Commit 58cfc1b2 authored by Tom Niget's avatar Tom Niget

Make file references parseable by IDEs

parent b1f20e2a
...@@ -48,7 +48,7 @@ def exception_hook(exc_type, exc_value, tb): ...@@ -48,7 +48,7 @@ def exception_hook(exc_type, exc_value, tb):
filename = tb.tb_frame.f_code.co_filename filename = tb.tb_frame.f_code.co_filename
line_no = tb.tb_lineno line_no = tb.tb_lineno
print(cf.red(f"File \"{filename}\", line {line_no}, in {cf.green(name)}"), end="") print(cf.red(f"File {filename}:{line_no}, in {cf.green(name)}"), end="")
if info := local_vars.get("TB", None): if info := local_vars.get("TB", None):
print(f": {cf.magenta(info)}\x1b[24m") print(f": {cf.magenta(info)}\x1b[24m")
...@@ -63,8 +63,8 @@ def exception_hook(exc_type, exc_value, tb): ...@@ -63,8 +63,8 @@ def exception_hook(exc_type, exc_value, tb):
last_node.lineno = 1 last_node.lineno = 1
print(ast.unparse(last_node)) print(ast.unparse(last_node))
return return
print(f"In file \"{cf.white(last_file)}\", line {last_node.lineno}")
print(f"From {last_node.lineno}:{last_node.col_offset} to {last_node.end_lineno}:{last_node.end_col_offset}") print(f"From {last_node.lineno}:{last_node.col_offset} to {last_node.end_lineno}:{last_node.end_col_offset}")
print(f"In file {cf.white(last_file)}:{last_node.lineno}")
with open(last_file, "r", encoding="utf-8") as f: with open(last_file, "r", encoding="utf-8") as f:
code = f.read() code = f.read()
hg = (str(highlight(code, True)) hg = (str(highlight(code, True))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment