mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-07-18 00:45:19 +00:00
Merge pull request #1 from sizhky/jupyter-notebook-5-compatibility
Compatibility with jupyter notebooks
This commit is contained in:
commit
d473540152
1 changed files with 5 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ if pycompat.PY2:
|
|||
|
||||
ipython_filename_pattern = re.compile('^<ipython-input-([0-9]+)-.*>$')
|
||||
ansible_filename_pattern = re.compile(r'^(.+\.zip)[/|\\](ansible[/|\\]modules[/|\\].+\.py)$')
|
||||
ipykernel_filename_pattern = re.compile('^/var/folders/.*/ipykernel_\d+/\d+.py$')
|
||||
RETURN_OPCODES = {
|
||||
'RETURN_GENERATOR', 'RETURN_VALUE', 'RETURN_CONST',
|
||||
'INSTRUMENTED_RETURN_GENERATOR', 'INSTRUMENTED_RETURN_VALUE',
|
||||
|
|
@ -74,6 +75,10 @@ def get_path_and_source_from_frame(frame):
|
|||
if source is None:
|
||||
ipython_filename_match = ipython_filename_pattern.match(file_name)
|
||||
ansible_filename_match = ansible_filename_pattern.match(file_name)
|
||||
ipykernel_filename_match = ipykernel_filename_pattern.match(file_name)
|
||||
if ipykernel_filename_match:
|
||||
import linecache
|
||||
_, _, source, _ = linecache.cache.get(file_name)
|
||||
if ipython_filename_match:
|
||||
entry_number = int(ipython_filename_match.group(1))
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue