def _cbPutMultipleNext(
            self, previousResult, files, remotePath, single=False):
        """
        Perform an upload for the next file in the list of local files.

        @param previousResult: Result form previous file form the list.
        @type previousResult: L{str}

        @param files: List of local files.
        @type files: C{list} of L{str}

        @param remotePath: Remote path for the request relative to current
            working directory.
        @type remotePath: L{str}

        @param single: A flag which signals if this is a transfer for a single
            file in which case we use the exact remote path
        @type single: L{bool}

        @return: A deferred which fires when transfer is done.
        """
        if isinstance(previousResult, failure.Failure):
            self._printFailure(previousResult)
        elif previousResult:
            if isinstance(previousResult, unicode):
                previousResult = previousResult.encode("utf-8")
            self._writeToTransport(previousResult)
            if not previousResult.endswith(b'\n'):
                self._writeToTransport(b'\n')

        currentFile = None
        while files and not currentFile:
            try:
                currentFile = files.pop(0)
                localStream = open(currentFile, 'rb')
            except:
                self._printFailure(failure.Failure())
                currentFile = None

        # No more files to transfer.
        if not currentFile:
            return None

        if single:
            remote = remotePath
        else:
            name = os.path.split(currentFile)[1]
            remote = os.path.join(remotePath, name)
            log.msg((name, remote, remotePath))

        d = self._putRemoteFile(localStream, remote)
        d.addBoth(self._cbPutMultipleNext, files, remotePath)
        return d

        Perform an upload for the next file in the list of local files.

        @param previousResult: Result form previous file form the list.
        @type previousResult: L{str}

        @param files: List of local files.
        @type files: C{list} of L{str}

        @param remotePath: Remote path for the request relative to current
            working directory.
        @type remotePath: L{str}

        @param single: A flag which signals if this is a transfer for a single
            file in which case we use the exact remote path
        @type single: L{bool}

        @return: A deferred which fires when transfer is done.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/scripts/cftp.py