def encode_multipart_formdata(self):
        """Encodes data for use in an HTTP request.

        Parameters:
            fields - the fields to be encoded.  This should be a dict in a
                     key:value format
            files  - the files to be encoded.  This should be a dict in a
                     key:dict, filename:value and content:value format
        """
        if not (self._fields or self._files):
            return None, None

        NEWLINE = b'\r\n'
        BOUNDARY = self._make_mime_boundary()
        content = BytesIO()

        for key in self._fields:
            content.write(b'--' + BOUNDARY + NEWLINE)
            content.write(b'Content-Disposition: form-data; '
                          b'name="%s"' % key.encode('utf-8'))
            content.write(NEWLINE + NEWLINE)

            if isinstance(self._fields[key], six.binary_type):
                content.write(self._fields[key] + NEWLINE)
            else:
                content.write(six.text_type(self._fields[key]).encode('utf-8')
                              + NEWLINE)

        for key in self._files:
            filename = self._files[key]['filename']
            value = self._files[key]['content']

            mime_type = mimetypes.guess_type(filename)[0]
            if mime_type:
                mime_type = mime_type.encode('utf-8')
            else:
                mime_type = b'application/octet-stream'

            content.write(b'--' + BOUNDARY + NEWLINE)
            content.write(b'Content-Disposition: form-data; name="%s"; '
                          % key.encode('utf-8'))
            content.write(b'filename="%s"' % filename.encode('utf-8')
                          + NEWLINE)
            content.write(mime_type % b'Content-Type: %s' + NEWLINE)
            content.write(NEWLINE)

            if isinstance(value, six.text_type):
                content.write(value.encode('utf-8'))
            else:
                content.write(value)

            content.write(NEWLINE)

        content.write(b'--' + BOUNDARY + b'--' + NEWLINE + NEWLINE)
        content_type = b'multipart/form-data; boundary=%s' % BOUNDARY

        return content_type, content.getvalue()
dataset/ETHPy150Open reviewboard/rbtools/rbtools/api/request.py/HttpRequest.encode_multipart_formdata/swapped operands of `%`