Attempt to open file located at file_location in the default web
    browser.
423971
def open_in_browser(file_location):
    """"""

    # If just the name of the file was given, check if it's in the Current
    # Working Directory.
    if not os.path.isfile(file_location):
        file_location = os.path.join(os.getcwd(), file_location)
    if not os.path.isfile(file_location):
        raise IOError("\n\nFile not found.")

    #  For some reason OSX requires this adjustment (tested on 10.10.4)
    if sys.platform == "darwin":
        file_location = "file:///"+file_location

    new = 2  # open in a new tab, if possible
    webbrowser.get().open(file_location, new=new)
895643
def open(self, file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None):
        
        urn = Urn(file)
        urn_path = urn.path()

        remote_file_exists = self.check(urn_path)

        if not remote_file_exists:
            if 'r' in mode:
                raise RemoteResourceNotFound(urn_path)
        elif self.is_dir(urn_path):
            raise OptionNotValid(name='file', value=file)

        with tempfile.TemporaryDirectory() as temp_dir:
            local_path = f'{temp_dir}{os.path.sep}{file}'

            if remote_file_exists:
                self.download_file(file, local_path)
            else:
                if ('w' in mode or 'a' in mode or 'x' in mode) and os.path.sep in local_path:
                    os.makedirs(local_path.rsplit(os.path.sep, 1)[0], exist_ok=True)

            with open(file=local_path, mode=mode, buffering=buffering, encoding=encoding, errors=errors,
                      newline=newline, closefd=closefd, opener=opener) as f:
                yield f

            if 'w' in mode or 'a' in mode or 'x' in mode:
                self.upload_file(file, local_path)
576959
synchronized void openInfo() throws IOException {
    if (src == null && blocks == null) {
      throw new IOException("No file provided to open");
    }

    LocatedBlocks newInfo = src != null ? 
                            getLocatedBlocks(src, 0, prefetchSize) : blocks;
                            
    if (newInfo == null) {
      throw new FileNotFoundException("Cannot open filename " + src);
    }

    // I think this check is not correct. A file could have been appended to
    // between two calls to openInfo().
    if (locatedBlocks != null && !locatedBlocks.isUnderConstruction() &&
        !newInfo.isUnderConstruction()) {
      Iterator<LocatedBlock> oldIter = locatedBlocks.getLocatedBlocksCopy()
          .iterator();
      Iterator<LocatedBlock> newIter = newInfo.getLocatedBlocks().iterator();
      while (oldIter.hasNext() && newIter.hasNext()) {
        if (! oldIter.next().getBlock().equals(newIter.next().getBlock())) {
          throw new IOException("Blocklist for " + src + " has changed!");
        }
      }
    }

    // if the file is under construction, then fetch size of last block
    // from datanode.
    if (newInfo.isUnderConstruction() && newInfo.locatedBlockCount() > 0) {
      LocatedBlock last = newInfo.get(newInfo.locatedBlockCount()-1);
      if (last.getLocations().length > 0) {
        try {
          Block newBlock = getBlockInfo(last);
          // only if the block has data (not null)
          if (newBlock != null) {
            long newBlockSize = newBlock.getNumBytes();
            newInfo.setLastBlockSize(newBlock.getBlockId(), newBlockSize);
          }
        } catch (IOException e) {
          DFSClient.LOG.debug("DFSClient file " + src + 
                    " is being concurrently append to" +
                    " but datanodes probably does not have block " +
                    last.getBlock(), e);
        }
      }
    }
    this.locatedBlocks = new DFSLocatedBlocks(newInfo, locatedBlockExpireTimeout);
    this.currentNode = null;
    if (!newInfo.isUnderConstruction()) {
      // No block should be under construction if the file is finalized.
      isCurrentBlockUnderConstruction = false;
    }
  }
296857
def get_file(self, file_path, mode="r"):
        
        return open(self.p(file_path), mode=mode)
472742
def file_uri(fname):
    """"""
    if os.name == 'nt':
        # Local file
        if re.search(r'^[a-zA-Z]:', fname):
            return 'file:///' + fname
        # UNC based path
        else:
            return 'file://' + fname
    else:
        return 'file://' + fname
1135109
def load(self, name, location='local'):
        """"""
        path = self._get_path(name, location, file_ext='.json')
        if op.exists(path):
            return _load_json(path)
        path = self._get_path(name, location, file_ext='.pkl')
        if op.exists(path):
            return _load_pickle(path)
        logger.debug("The file `%s` doesn't exist.", path)
        return {}
324291
def open(self):
        """"""
        with open(self.filename, 'rb') as file_open:
            binary = file_open.read()

        try:
            return binary.decode()
        except UnicodeDecodeError:
            encoding = get_encoding(binary)
            try:
                return binary.decode(encoding)
            except LookupError:
                return binary.decode(errors='ignore')
            except:  # pylint: disable=W0702
                open_error(self.filename)
        except:  # pylint: disable=W0702
            open_error(self.filename)
1279083
def display_index(config):
    
    browser = config["web browser"].lower()
    data_dir = Path(config["data dir"])
    if browser in webbrowser._browsers:
        b = webbrowser.get(browser)
    else:
        if browser != "default":
            logger.warning(
                "Couldn't find '%s' browser. Falling back to default.", browser
            )
        b = webbrowser.get()
    index_file = data_dir.joinpath("index.html")
    if not index_file.exists():
        logger.error("File doesn't exist: %s", index_file.as_posix())
        raise FileNotFoundError("Index file doesn't exist")
    else:
        logger.info("Opening %s in '%s'", index_file.as_posix(), b.name)
        b.open(index_file.as_uri())
831590
def open(self, _file, target=DEFAULT_TARGET):
        
        # Close any existing BFD structure instance. 
        self.close()

        #
        # STEP 1. Open the BFD pointer.
        #
        # Determine if the user passed a file-descriptor or a _file and
        # proceed accordingly.
        if type(_file) is FileType:
            # The user specified a file descriptor.
            filename = _file.name

            if islink(filename):
                raise BfdException("Symlinks file-descriptors are not valid")
                    
            try:
                self._ptr = _bfd.fdopenr(filename, target, dup(_file.fileno()))
            except Exception, err:
                raise BfdException(
                    "Unable to open file-descriptor %s : %s" % (filename, err))

        elif type(_file) is StringType:
            # The user spcified a filaname so first check if file exists.
            filename = _file
            try:
                with open(_file): pass
            except IOError:
                raise BfdException("File %s does not exist." % filename)

            #
            # Proceed to open the specified file and create a new BFD.
            #
            try:
                self._ptr = _bfd.openr(filename, target)
            except (TypeError, IOError), err:
                raise BfdException(
                    "Unable to open file %s : %s" % (filename, err))

        elif type(_file) is IntType:
            # The user specified an already-open BFD pointer so we avoid any
            # further open operation and move on to file format recognition.
            self._ptr = _file

        else:
            raise BfdException(
                "Invalid file type specified for open operation (%r)" % _file)

        #
        # STEP 2. Determine file format of the BFD.
        #
        # Now that the BFD is open we'll proceed to determine its file format.
        # We'll use the objdump logic to determine it and raise an error in
        # case we were unable to get it right.
        #
        try:
            # Type opening it as an archieve and if it success then check
            # subfiles.
            if _bfd.check_format(self._ptr, BfdFormat.ARCHIVE):
                # Set current format and store the inner file list.
                self.file_format = BfdFormat.ARCHIVE

                self.__populate_archive_files()
            else:
                # DO NOT USE bfd_check_format_matches() becuase its not tested.
                # An implementation example if on objdump.c at function
                # display_bfd().
                if _bfd.check_format(self._ptr, BfdFormat.OBJECT):
                    self.file_format = BfdFormat.OBJECT

                elif _bfd.check_format(self._ptr, BfdFormat.CORE):
                    self.file_format = BfdFormat.CORE

                else:
                    pass
                    raise BfdException(_bfd.get_last_error_message())

        except TypeError, err:
            raise BfdException(
                "Unable to initialize file format : %s" % err)

        #
        # STEP 3. Extract inner sections and symbolic information.
        #
        if self._ptr is not None:
            # If the file is a valid BFD file format but not an archive then
            # get its sections and symbolic information (if any).
            if self.file_format in [BfdFormat.OBJECT, BfdFormat.CORE]:
                self.__populate_sections()
                self.__populate_symbols()
304375
def open_file(path):
    """"""
    if sys.platform=='win32':
        os.startfile(path)
        #subprocess.Popen(['start', path], shell= True)
    
    elif sys.platform=='darwin':
        subprocess.Popen(['open', path])
    
    else:
        try:
            subprocess.Popen(['xdg-open', path])
        except OSError:
            pass
322550
function open(url, location, noFlash) {
        console.assert(url.substr(0, 7) === "file://", "Cannot open non-file URLs");

        var result = new $.Deferred();

        url = _urlWithoutQueryString(url);
        // Extract the path, also strip the third slash when on Windows
        var path = url.slice(brackets.platform === "win" ? 8 : 7);
        // URL-decode the path ('%20' => ' ')
        path = decodeURI(path);
        var promise = CommandManager.execute(Commands.FILE_OPEN, {fullPath: path});
        promise.done(function onDone(doc) {
            if (location) {
                openLocation(location, noFlash);
            }
            result.resolve();
        });
        promise.fail(function onErr(err) {
            console.error(err);
            result.reject(err);
        });

        return result.promise();
    }
60541
function resolveFileToURL(output, filePath) {
    // Convert /test.png -> test.png
    filePath = LocationUtils.toAbsolute(filePath, '', '');

    var page = output.getPage(filePath);

    // if file is a page, return correct .html url
    if (page) {
        filePath = fileToURL(output, filePath);
    }

    return LocationUtils.normalize(filePath);
}
183428
def open(self, external_dir=None):
        
        if self.kind == 'data':
            with io.BytesIO(self._data.data) as f:
                yield f
        elif self.kind == 'external':
            filepath = self._data.linked_file[b'fullPath'].value
            filepath = filepath.replace('\x00', '').replace('file://', '')
            if not os.path.exists(filepath):
                filepath = self._data.linked_file[b'relPath'].value
                filepath = filepath.replace('\x00', '')
                if external_dir is not None:
                    filepath = os.path.join(external_dir, filepath)
            if not os.path.exists(filepath):
                raise FileNotFoundError(filepath)
            with open(filepath, 'rb') as f:
                yield f
        else:
            raise NotImplementedError('alias is not supported.')
511986
def open(self, directory=None, filename=None, mode="rb"):
        """"""
        path = os.path.join(directory, filename)
        return open(path, mode)
1102764
def _locate_file(f, base_dir):
    
    if base_dir == None:
        return f
    file_name = os.path.join(base_dir, f)
    real = os.path.realpath(file_name)
    #print_v('- Located %s at %s'%(f,real))
    return real
1320726
def open_window(path):
    """"""
    if 'pathlib' in modules:
        try:
            call(["open", "-R", str(Path(str(path)))])
        except FileNotFoundError:
            Popen(r'explorer /select,' + str(Path(str(path))))
    else:
        print('pathlib module must be installed to execute open_window function')
224172
public static void openInDefaultBrowser(URL url) throws IOException {
        Runtime rt = Runtime.getRuntime();

        if (SystemUtils.IS_OS_WINDOWS) {
            rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
        } else if (SystemUtils.IS_OS_MAC) {
            rt.exec("open" + url);
        } else {
            String[] browsers = {"epiphany", "firefox", "mozilla", "konqueror",
                    "netscape", "opera", "links", "lynx"};

            StringBuilder cmd = new StringBuilder();
            for (int i = 0; i < browsers.length; i++)
                cmd.append(i == 0 ? "" : " || ").append(browsers[i]).append(" \"").append(url).append("\" ");

            rt.exec(new String[]{"sh", "-c", cmd.toString()});
        }
    }