Add a trace_lines util function
This commit is contained in:
parent
b43a431161
commit
109906043e
@ -17,6 +17,7 @@
|
||||
|
||||
"""Other utilities which don't fit anywhere else."""
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
|
||||
from PyQt5.QtCore import pyqtRemoveInputHook
|
||||
@ -50,3 +51,14 @@ def read_file(filename):
|
||||
fn = os.path.join(qutebrowser.basedir, filename)
|
||||
with open(fn, 'r', encoding='UTF-8') as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
def trace_lines(do_trace):
|
||||
def trace(frame, event, arg):
|
||||
print("{}, {}:{}".format(event, frame.f_code.co_filename,
|
||||
frame.f_lineno))
|
||||
return trace
|
||||
if do_trace:
|
||||
sys.settrace(trace)
|
||||
else:
|
||||
sys.settrace(None)
|
||||
|
Loading…
Reference in New Issue
Block a user