Open the file in the specified mode

        Parameters
        ----------
        mode : {'a', 'w', 'r', 'r+'}, default 'a'
            See HDFStore docstring or tables.open_file for info about modes
329931
def open(self, mode='a', **kwargs):
        
        tables = _tables()

        if self._mode != mode:

            # if we are changing a write mode to read, ok
            if self._mode in ['a', 'w'] and mode in ['r', 'r+']:
                pass
            elif mode in ['w']:

                # this would truncate, raise here
                if self.is_open:
                    raise PossibleDataLossError(
                        "Re-opening the file [{0}] with mode [{1}] "
                        "will delete the current file!"
                        .format(self._path, self._mode)
                    )

            self._mode = mode

        # close and reopen the handle
        if self.is_open:
            self.close()

        if self._complevel and self._complevel > 0:
            self._filters = _tables().Filters(self._complevel, self._complib,
                                              fletcher32=self._fletcher32)

        try:
            self._handle = tables.open_file(self._path, self._mode, **kwargs)
        except (IOError) as e:  # pragma: no cover
            if 'can not be written' in str(e):
                print(
                    'Opening {path} in read-only mode'.format(path=self._path))
                self._handle = tables.open_file(self._path, 'r', **kwargs)
            else:
                raise

        except (ValueError) as e:

            # trap PyTables >= 3.1 FILE_OPEN_POLICY exception
            # to provide an updated message
            if 'FILE_OPEN_POLICY' in str(e):
                e = ValueError(
                    "PyTables [{version}] no longer supports opening multiple "
                    "files\n"
                    "even in read-only mode on this HDF5 version "
                    "[{hdf_version}]. You can accept this\n"
                    "and not open the same file multiple times at once,\n"
                    "upgrade the HDF5 version, or downgrade to PyTables 3.0.0 "
                    "which allows\n"
                    "files to be opened multiple times at once\n"
                    .format(version=tables.__version__,
                            hdf_version=tables.get_hdf5_version()))

            raise e

        except (Exception) as e:

            # trying to read from a non-existent file causes an error which
            # is not part of IOError, make it one
            if self._mode == 'r' and 'Unable to open/create file' in str(e):
                raise IOError(str(e))
            raise
1059890
def fileish_open(fileish, mode):
    
    if mode is not None and any(m in mode for m in ['+', 'w', 'a', 'x']):
        attr = 'write'
    else:
        attr = 'read'
    if hasattr(fileish, attr) and hasattr(fileish, 'seek'):
        # BytesIO-like object
        return fileish
    elif isinstance(fileish, str):
        # Python2 - file path, file contents in the case of a TypeError
        # Python3 - file path
        try:
            return open(fileish, mode)
        except TypeError:
            return io.BytesIO(fileish)
    else:
        # Python 3 - file contents
        return io.BytesIO(fileish)
697119
def _raw_open(self, flags, mode=0o777):
        
        return self._accessor.open(self, flags, mode)
5181
def open(self, filepath, mode='w+b'):
        
        #Check if the filepath can be accessed and is writable before creating
        #the tempfile
        if not _isFileAccessible(filepath):
            raise IOError('File %s is not writable' % (filepath,))

        if filepath in self._files:
            with open(self._files[filepath], mode=mode) as tmpf:
                yield tmpf
        else:
            tempfilepath = None
            with tempfile.NamedTemporaryFile(delete=False, mode=mode) as tmpf:
                tempfilepath = tmpf.name
                yield tmpf
            self._files[filepath] = tempfilepath
524457
def _open_file_obj(f, mode="r"):
    
    if isinstance(f, six.string_types):
        if f.startswith(("http://", "https://")):
            file_obj = _urlopen(f)
            yield file_obj
            file_obj.close()
        else:
            with open(f, mode) as file_obj:
                yield file_obj
    else:
        yield f
520029
def open_tls_file(file_path, mode, private=True):
    

    containing_dir = os.path.dirname(file_path)
    fh = None
    try:
        if 'w' in mode:
            os.chmod(containing_dir, mode=0o755)
        fh = open(file_path, mode)
    except OSError as e:
        if 'w' in mode:
            os.makedirs(containing_dir, mode=0o755, exist_ok=True)
            os.chmod(containing_dir, mode=0o755)
            fh = open(file_path, 'w')
        else:
            raise
    yield fh
    mode = 0o600 if private else 0o644
    os.chmod(file_path, mode=mode)
    fh.close()
659527
def open(_mode = "rb")
      # NTFS module methods use miqfs instance accessors to
      # touch @boot_sector, @drive_root, @index_cache and @cache_hits
      # (and any other NTFS members that may come later)
      @din = ifs_getFile(@path, @miqfs)
      raise "File not found: '#{@path}'"    if @din.nil?
      mft_entry = @din.resolve(@miqfs.boot_sector)
      raise "File is directory: '#{@path}'" if @din.isDir?
      @data = mft_entry.attributeData || AttribData.new("", 0)
    end
463326
def open(self, filename, mode='r', bufsize=-1):
        
        sftp_client = self.open_sftp()
        return sftp_client.open(filename, mode, bufsize)
1162244
def _open_for_csv(name, mode):
    
    if sys.version_info[0] < 3:
        return open_rw(name, mode + 'b')
    return open_rw(name, mode, newline='', encoding='utf-8')
583357
def open(self, filename, mode='r', **kwargs):
        '''
        
        '''
        if 'r' in mode and not self.backend.exists(filename):
            raise FileNotFound(filename)
        return self.backend.open(filename, mode, **kwargs)
387741
def open_file(self, file_):
        
        with open(file_, 'r', encoding='utf-8') as file:
            text = ''
            for line in file:
                text += line
        return text
996272
def openfile(filename, mode="rt", *args, expanduser=False, expandvars=False,
             makedirs=False, **kwargs):
    """"""
    if filename in ("-", None):
        return sys.stdin if "r" in mode else sys.stdout
    if expanduser:
        filename = os.path.expanduser(filename)
    if expandvars:
        filename = os.path.expandvars(filename)
    if makedirs and ("a" in mode or "w" in mode):
        parentdir = os.path.dirname(filename)
        if not os.path.isdir(parentdir):
            os.makedirs(parentdir)
    if filename.endswith(".gz"):
        if gzip is None:
            raise NotImplementedError
        _open = gzip.open
    elif filename.endswith(".bz2"):
        if bz2 is None:
            raise NotImplementedError
        _open = bz2.open
    elif filename.endswith(".xz") or filename.endswith(".lzma"):
        if lzma is None:
            raise NotImplementedError
        _open = lzma.open
    else:
        _open = open
    return _open(filename, mode, *args, **kwargs)
45771
def detect_mode(cls, **params):
        
        modes = []
        for mode in cls.modes:
            if params.get(mode) is not None:
                modes.append(mode)
        if len(modes) > 1:
            error_message = 'ambiguous mode, must be one of {}'
            modes_csv = ', '.join(list(cls.modes))
            raise ValueError(error_message.format(modes_csv))
        return modes[0] if modes else cls.default_mode
1081902
def open(uri, mode, min_part_size=WEBHDFS_MIN_PART_SIZE):
    
    if mode == 'rb':
        return BufferedInputBase(uri)
    elif mode == 'wb':
        return BufferedOutputBase(uri, min_part_size=min_part_size)
    else:
        raise NotImplementedError('webhdfs support for mode %r not implemented' % mode)
193103
def open_file(self, access_mode="r"):
        
        try:
            with open(self, access_mode, encoding='utf-8') as file:
                return file.read()

        except IOError:
            print(self + " File not found.")
            sys.exit(0)
1199787
def open(mode = "r")
      # Ext4 module methods use miqfs instance accessors to touch @boot_sector.
      @mode = mode.downcase
      @de = ifs_getFile(@path, @miqfs)
      raise "File is directory: '#{@path}'" if  @de && @de.isDir?

      if mode.include?("r")
        raise "File not found: '#{@path}'" if @de.nil?
        @inode = @miqfs.superblock.getInode(@de.inode)
      end
    end
957052
def askopenfile(mode="r", **options):
    ""

    filename = askopenfilename(**options)
    if filename:
        return open(filename, mode)
    return None