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

Method open

Lib/webbrowser.py:275–300  ·  view source on GitHub ↗
(self, url, new=0, autoraise=True)

Source from the content-addressed store, hash-verified

273 return not p.wait()
274
275 def open(self, url, new=0, autoraise=True):
276 sys.audit("webbrowser.open", url)
277 self._check_url(url)
278 if new == 0:
279 action = self.remote_action
280 elif new == 1:
281 action = self.remote_action_newwin
282 elif new == 2:
283 if self.remote_action_newtab is None:
284 action = self.remote_action_newwin
285 else:
286 action = self.remote_action_newtab
287 else:
288 raise Error("Bad 'new' parameter to open(); "
289 f"expected 0, 1, or 2, got {new}")
290
291 args = [arg.replace("%s", url).replace("%action", action)
292 for arg in self.remote_args]
293 args = [arg for arg in args if arg]
294 success = self._invoke(args, True, autoraise, url)
295 if not success:
296 # remote invocation failed, try straight way
297 args = [arg.replace("%s", url) for arg in self.args]
298 return self._invoke(args, False, False)
299 else:
300 return True
301
302
303class Mozilla(UnixBrowser):

Callers

nothing calls this directly

Calls 4

_invokeMethod · 0.95
_check_urlMethod · 0.80
ErrorClass · 0.70
replaceMethod · 0.45

Tested by

no test coverage detected