MCPcopy Index your code
hub / github.com/RustPython/RustPython / open

Method open

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

_invokeMethod · 0.95
ErrorClass · 0.70
replaceMethod · 0.45

Tested by

no test coverage detected