MCPcopy Index your code
hub / github.com/python/cpython / _open_in_browser

Function _open_in_browser

Lib/profiling/sampling/cli.py:627–650  ·  view source on GitHub ↗

Open a file or directory in the default web browser. Args: path: File path or directory path to open For directories (heatmap), opens the index.html file inside.

(path)

Source from the content-addressed store, hash-verified

625
626
627def _open_in_browser(path):
628 """Open a file or directory in the default web browser.
629
630 Args:
631 path: File path or directory path to open
632
633 For directories (heatmap), opens the index.html file inside.
634 """
635 abs_path = os.path.abspath(path)
636
637 # For heatmap directories, open the index.html file
638 if os.path.isdir(abs_path):
639 index_path = os.path.join(abs_path, 'index.html')
640 if os.path.exists(index_path):
641 abs_path = index_path
642 else:
643 print(f"Warning: Could not find index.html in {path}", file=sys.stderr)
644 return
645
646 file_url = f"file://{abs_path}"
647 try:
648 webbrowser.open(file_url)
649 except Exception as e:
650 print(f"Warning: Could not open browser: {e}", file=sys.stderr)
651
652
653def _handle_output(collector, args, pid, mode):

Callers 2

_handle_outputFunction · 0.85
_handle_replayFunction · 0.85

Calls 5

abspathMethod · 0.45
isdirMethod · 0.45
joinMethod · 0.45
existsMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…