def call(self, file_, mode='r', buffering=-1, encoding=None,
             errors=None, newline=None, closefd=True, opener=None,
             open_modes=None):
        """Return a file-like object with the contents of the target
        file object.

        Args:
            file_: Path to target file or a file descriptor.
            mode: Additional file modes (all modes in `open()` are supported).
            buffering: ignored. (Used for signature compliance with
                __builtin__.open)
            encoding: The encoding used to encode unicode strings / decode
                bytes.
            errors: (str) Defines how encoding errors are handled.
            newline: Controls universal newlines, passed to stream object.
            closefd: If a file descriptor rather than file name is passed,
                and this is set to `False`, then the file descriptor is kept
                open when file is closed.
            opener: not supported.
            open_modes: Modes for opening files if called from low-level API.

        Returns:
            A file-like object containing the contents of the target file.

        Raises:
            IOError, OSError depending on Python version / call mode:
                - if the target object is a directory
                - on an invalid path
                - if the file does not exist when it should
                - if the file exists but should not
                - if permission is denied
            ValueError: for an invalid mode or mode combination
        """
        binary = 'b' in mode
        newline, open_modes = self._handle_file_mode(mode, newline, open_modes)

        file_object, file_path, filedes, real_path = self._handle_file_arg(
            file_)
        if not filedes:
            closefd = True

        error_fct = (self.filesystem.raise_os_error if self.raw_io
                     else self.filesystem.raise_io_error)
        if (open_modes.must_not_exist and
                (file_object or self.filesystem.islink(file_path) and
                 not self.filesystem.is_windows_fs)):
            error_fct(errno.EEXIST, file_path)
        if file_object:
            if (not is_root() and
                    ((open_modes.can_read and
                      not file_object.st_mode & PERM_READ)
                     or (open_modes.can_write and
                         not file_object.st_mode & PERM_WRITE))):
                error_fct(errno.EACCES, file_path)
            if open_modes.can_write:
                if open_modes.truncate:
                    file_object.set_contents('')
        else:
            if open_modes.must_exist:
                error_fct(errno.ENOENT, file_path)
            if self.filesystem.islink(file_path):
                link_object = self.filesystem.resolve(file_path,
                                                      follow_symlinks=False)
                target_path = link_object.contents
            else:
                target_path = file_path
            if self.filesystem.ends_with_path_separator(target_path):
                error = (errno.EINVAL if self.filesystem.is_windows_fs
                         else errno.ENOENT if self.filesystem.is_macos
                         else errno.EISDIR)
                error_fct(error, file_path)
            file_object = self.filesystem.create_file_internally(
                real_path, create_missing_dirs=False,
                apply_umask=True, raw_io=self.raw_io)

        if S_ISDIR(file_object.st_mode):
            if self.filesystem.is_windows_fs:
                error_fct(errno.EACCES, file_path)
            else:
                error_fct(errno.EISDIR, file_path)

        # If you print obj.name, the argument to open() must be printed.
        # Not the abspath, not the filename, but the actual argument.
        file_object.opened_as = file_path
        if open_modes.truncate:
            current_time = time.time()
            file_object.st_mtime = current_time
            if not self.filesystem.is_windows_fs:
                file_object.st_ctime = current_time

        fakefile = FakeFileWrapper(file_object,
                                   file_path,
                                   update=open_modes.can_write,
                                   read=open_modes.can_read,
                                   append=open_modes.append,
                                   delete_on_close=self._delete_on_close,
                                   filesystem=self.filesystem,
                                   newline=newline,
                                   binary=binary,
                                   closefd=closefd,
                                   encoding=encoding,
                                   errors=errors,
                                   raw_io=self.raw_io,
                                   use_io=self._use_io)
        if filedes is not None:
            fakefile.filedes = filedes
            # replace the file wrapper
            self.filesystem.open_files[filedes].append(fakefile)
        else:
            fakefile.filedes = self.filesystem._add_open_file(fakefile)
        return fakefile
def call ( self , file_ , mode = 'r' , buffering = - 1 , encoding = None , errors = None , newline = None , closefd = True , opener = None , open_modes = None ) : binary = 'b' in mode newline , open_modes = self . _handle_file_mode ( mode , newline , open_modes ) file_object , file_path , filedes , real_path = self . _handle_file_arg ( file_ ) if not filedes : closefd = True error_fct = ( self . filesystem . raise_os_error if self . raw_io else self . filesystem . raise_io_error ) if ( open_modes . must_not_exist and ( file_object or self . filesystem . islink ( file_path ) and not self . filesystem . is_windows_fs ) ) : error_fct ( errno . EEXIST , file_path ) if file_object : if ( not is_root ( ) and ( ( open_modes . can_read and not file_object . st_mode & PERM_READ ) or ( open_modes . can_write and not file_object . st_mode & PERM_WRITE ) ) ) : error_fct ( errno . EACCES , file_path ) if open_modes . can_write : if open_modes . truncate : file_object . set_contents ( '' ) else : if open_modes . must_exist : error_fct ( errno . ENOENT , file_path ) if self . filesystem . islink ( file_path ) : link_object = self . filesystem . resolve ( file_path , follow_symlinks = False ) target_path = link_object . contents else : target_path = file_path if self . filesystem . ends_with_path_separator ( target_path ) : error = ( errno . EINVAL if self . filesystem . is_windows_fs else errno . ENOENT if self . filesystem . is_macos else errno . EISDIR ) error_fct ( error , file_path ) file_object = self . filesystem . create_file_internally ( real_path , create_missing_dirs = False , apply_umask = True , raw_io = self . raw_io ) if S_ISDIR ( file_object . st_mode ) : if self . filesystem . is_windows_fs : error_fct ( errno . EACCES , file_path ) else : error_fct ( errno . EISDIR , file_path ) file_object . opened_as = file_path if open_modes . truncate : current_time = time . time ( ) file_object . st_mtime = current_time if not self . filesystem . is_windows_fs : file_object . st_ctime = current_time fakefile = FakeFileWrapper ( file_object , file_path , update = open_modes . can_write , read = open_modes . can_read , append = open_modes . append , delete_on_close = self . _delete_on_close , filesystem = self . filesystem , newline = newline , binary = binary , closefd = closefd , encoding = encoding , errors = errors , raw_io = self . raw_io , use_io = self . _use_io ) if filedes is not None : fakefile . filedes = filedes self . filesystem . open_files [ filedes ] . append ( fakefile ) else : fakefile . filedes = self . filesystem . _add_open_file ( fakefile ) return fakefile
Return a file-like object with the contents of the target
        file object.

        Args:
            file_: Path to target file or a file descriptor.
            mode: Additional file modes (all modes in `open()` are supported).
            buffering: ignored. (Used for signature compliance with
                __builtin__.open)
            encoding: The encoding used to encode unicode strings / decode
                bytes.
            errors: (str) Defines how encoding errors are handled.
            newline: Controls universal newlines, passed to stream object.
            closefd: If a file descriptor rather than file name is passed,
                and this is set to `False`, then the file descriptor is kept
                open when file is closed.
            opener: not supported.
            open_modes: Modes for opening files if called from low-level API.

        Returns:
            A file-like object containing the contents of the target file.

        Raises:
            IOError, OSError depending on Python version / call mode:
                - if the target object is a directory
                - on an invalid path
                - if the file does not exist when it should
                - if the file exists but should not
                - if permission is denied
            ValueError: for an invalid mode or mode combination