mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-07-19 09:23:48 +00:00
When tracing 'call' events, skip lines containing decorators to print actual function name.
Python syntax expects function decorators in a separate line so the all lines starting with '@' can be safely skipped.
This commit is contained in:
parent
ff4e64c457
commit
90951065d3
1 changed files with 9 additions and 2 deletions
|
|
@ -181,9 +181,16 @@ class Tracer:
|
|||
### Finished newish and modified variables. ###########################
|
||||
|
||||
now_string = datetime_module.datetime.now().time().isoformat()
|
||||
source_line = get_source_from_frame(frame)[frame.f_lineno - 1]
|
||||
line_no = frame.f_lineno
|
||||
source_line = get_source_from_frame(frame)[line_no - 1]
|
||||
if event == 'call':
|
||||
# Skip lines containing function decorators to print actual
|
||||
# function name
|
||||
while source_line.lstrip()[0] == '@':
|
||||
line_no += 1
|
||||
source_line = get_source_from_frame(frame)[line_no - 1]
|
||||
self.write('{indent}{now_string} {event:9} '
|
||||
'{frame.f_lineno:4} {source_line}'.format(**locals()))
|
||||
'{line_no:4} {source_line}'.format(**locals()))
|
||||
return self.trace
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue