def encode_multipart(self, params, files):
        """
        Encodes a set of parameters (typically a name/value list) and
        a set of files (a list of (name, filename, file_body)) into a
        typical POST body, returning the (content_type, body).
        """
        boundary = random.random() % '----------a_BoUnDaRy%s$'
        content_type = 'multipart/form-data; boundary=%s' % boundary
        if six.PY3:
            boundary = boundary.encode('ascii')

        lines = []
        for key, value in params:
            lines.append(b'--'+boundary)
            line = 'Content-Disposition: form-data; name="%s"' % key
            if six.PY3:
                line = line.encode('utf8')
            lines.append(line)
            lines.append(b'')
            line = value
            if six.PY3 and isinstance(line, six.text_type):
                line = line.encode('utf8')
            lines.append(line)
        for file_info in files:
            key, filename, value = self._get_file_info(file_info)
            lines.append(b'--'+boundary)
            line = ('Content-Disposition: form-data; name="%s"; filename="%s"'
                         % (key, filename))
            if six.PY3:
                line = line.encode('utf8')
            lines.append(line)
            fcontent = mimetypes.guess_type(filename)[0]
            line = ('Content-Type: %s'
                    % (fcontent or 'application/octet-stream'))
            if six.PY3:
                line = line.encode('utf8')
            lines.append(line)
            lines.append(b'')
            lines.append(value)
        lines.append(b'--' + boundary + b'--')
        lines.append(b'')
        body = b'\r\n'.join(lines)
        return content_type, body
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Paste-2.0.1/paste/fixture.py/TestApp.encode_multipart/swapped operands of `%`