MCPcopy Create free account
hub / github.com/datapane/datapane / open_in_browser

Function open_in_browser

python-client/src/datapane/client/utils.py:111–124  ·  view source on GitHub ↗

Open the given URL in the user's browser

(url: str)

Source from the content-addressed store, hash-verified

109################################################################################
110# Output
111def open_in_browser(url: str):
112 """Open the given URL in the user's browser"""
113 from datapane.ipython.environment import get_environment
114
115 environment = get_environment()
116
117 # TODO - this is a bit of a hack, but works for now. JupyterLab (Codespaces) doesn't support webbrowser.open.
118 if environment.is_notebook_environment and not environment.can_open_links_from_python:
119 ip = environment.get_ipython()
120 ip.run_cell_magic("javascript", "", f'window.open("{url}", "_blank")')
121 else:
122 import webbrowser
123
124 webbrowser.open(url, new=1)
125
126
127class MarkdownFormatter(string.Formatter):

Callers 1

__call__Method · 0.90

Calls 2

get_environmentFunction · 0.90
openMethod · 0.80

Tested by

no test coverage detected