Open the given HTML file in a browser.
489398
def open_in_browser(self, outfile):
        
        if self.browser == 'default':
            webbrowser.open('file://%s' % outfile)
        else:
            browser = webbrowser.get(self.browser)
            browser.open('file://%s' % outfile)
1152778
def load_script(browser, url):
    """"""
    if browser.current_url.startswith('file:'):
        url = 'https:' + url
    browser.execute_script("""
    var script_tag = document.createElement("script");
    script_tag.setAttribute("type", "text/javascript");
    script_tag.setAttribute("src", arguments[0]);
    document.getElementsByTagName("head")[0].appendChild(script_tag);
    """, url)

    sleep(1)
594722
def _open_url(self):
        """"""
        load_text = "Loading URL..." if not self.run else "Executing: {}".format(self.run)
        if os.environ.get('BROWSER') not in ['elinks', 'links', 'w3m', 'lynx']:
            self._footer_start_thread(load_text, 5)
613595
def grep(filename, tag, firstOccurrence=False):
    """"""
    import re

    try:
        afile = open(filename, "r")
    except:
        print("Error in utils.grep(): cannot open file", filename)
        exit()
    content = None
    for line in afile:
        if re.search(tag, line):
            content = line.split()
            if firstOccurrence:
                break
    if content:
        if len(content) == 2:
            content = content[1]
        else:
            content = content[1:]
    afile.close()
    return content
600352
def view(url: str, **kwargs) -> bool:
    
    kwargs.setdefault('headers', DEFAULT_HEADERS)
    html = requests.get(url, **kwargs).content
    if b'<base' not in html:
        repl = f'<head><base href="{url}">'
        html = html.replace(b'<head>', repl.encode('utf-8'))
    fd, fname = tempfile.mkstemp('.html')
    os.write(fd, html)
    os.close(fd)
    return webbrowser.open(f'file://{fname}')
1234791
private InputStream safeOpen(String file) {
    URL url = bundle.getEntry(file);
    if (url != null) {
      try {
        return url.openStream();
      } catch (IOException e) {
        // if we get an IOException just return null for default page.
      }
    }
    return null;
  }
631477
def open(self, encoding=None):
        """"""
        try:
            if IS_GZIPPED_FILE.search(self._filename):
                _file = gzip.open(self._filename, 'rb')
            else:
                if encoding:
                    _file = io.open(self._filename, 'r', encoding=encoding, errors='replace')
                elif self._encoding:
                    _file = io.open(self._filename, 'r', encoding=self._encoding, errors='replace')
                else:
                    _file = io.open(self._filename, 'r', errors='replace')
        except IOError, e:
            self._log_warning(str(e))
            _file = None
            self.close()

        return _file
1091443
def open(cls, sock, chunk_type, isatty, chunk_eof_type=None, buf_size=None, select_timeout=None):
    """"""
    with cls.open_multi(sock,
                        (chunk_type,),
                        (isatty,),
                        chunk_eof_type,
                        buf_size,
                        select_timeout) as ctx:
      yield ctx
1267822
function html(req, res) {
  fs.readFile(path.join(__dirname, 'index.html'), function read(err, file) {
    if (err) throw err;

    res.setHeader('Content-Length', file.length);
    res.writeHead(200, { 'Content-Type': 'text/html' });

    res.end(file);
  });
}
220669
public static void openLink(String url) throws IOException, URISyntaxException {
        Desktop.getDesktop().browse(new URI(url));
    }
443872
def url_or_file_open(uri):
    """"""
    if (not re.match(r'''\w+:''', uri)):
        uri = 'file:' + uri
    return(urlopen(uri))
816219
def execute_from_file(self, url, file_var):
        '''
        

        '''
        if isinstance(file_var, file):
            f = file_var
        elif isinstance(file_var, str):
            try:
                f = open(file_var)
            except IOError, e:
                raise e
        else:
            raise TypeError("This function only accepts a 'file' type  or file path")

        inputs = json.loads(f.read())
        resp = self.execute(url, inputs)
        return resp
1261169
public static final void launchBrowser(String url) throws IOException {
		try {
			if (isMac()) {
				Class macUtils = Class.forName("com.apple.mrj.MRJFileUtils");
				Method openURL = macUtils.getDeclaredMethod("openURL", new Class[] {String.class});
				openURL.invoke(null, new Object[] {url});
			}
			else if (isWindows())
				Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
			else { //assume Unix or Linux
	            String[] browsers = {
	               "firefox", "opera", "konqueror", "mozilla", "netscape" };
	            String browser = null;
	            for (int count = 0; count < browsers.length && browser == null; count++)
	               if (Runtime.getRuntime().exec(new String[] {"which", browsers[count]}).waitFor() == 0)
	                  browser = browsers[count];
	            if (browser == null)
	               throw new Exception("Could not find web browser.");
	            else
	               Runtime.getRuntime().exec(new String[] {browser, url});
	            }
	         }
	      catch (Exception e) {
	         throw new IOException("Error attempting to launch web browser");
	      }
	}
1001149
def open(self, new=1):
        
        import webbrowser
        webbrowser.open(self.url, new=new)
1307772
def open_file(self) :
        """"""
        if self.isdir() : raise Exception("FSQuery tried to open a directory as a file : %s" % self.abs)
        return open(self.abs)
160497
def open_in_browser(self, n_times):
        

        for _ in range(n_times):
            webbrowser.open(self.url)
924903
def _open(filename, mode='r', buffering=0):
    """"""
    if mode not in ('r', 'rb', 'rU'):
        raise RuntimeError("Invalid open file mode, must be 'r', 'rb', or 'rU'")
    if buffering > MAX_OPEN_BUFFER:
        raise RuntimeError("Invalid buffering value, max buffer size is {}".format(MAX_OPEN_BUFFER))
    return open(filename, mode, buffering)