def DoMultipart(
      self, url, params, filename, input_filename=None, input_file=None):
    """Make a form/multipart POST request and return the response.

    Args:
      url: str, url like '/foo.html', not 'http://host/foo.html'
      params: dict, text parameters to send as text/plain form elements
      filename: str, filename to be supplied in headers, it is NOT read from
      input_filename: str, optional, filename to read from
      input_file: file, optional, file object to read from
    Returns:
      Response object
    Raises:
      Error: if input is invalid
      HTTPError: if a connection level error occured
    """
    if not input_filename and not input_file:
      raise Error('must supply input_filename or input_file')

    boundary = mimetools.choose_boundary()
    content_type = 'application/octet-stream'
    headers = {
        'Content-Type': 'multipart/form-data; boundary=%s' % boundary,
    }

    close_input_file = False
    if input_file is None:
      close_input_file = True
      input_file = open(input_filename, 'r')

    crlf = '\r\n'
    body = []

    # TODO(user): This method should support sending multiple files,
    # not just one.
    tmp_body = []
    tmp_body.append(boundary % '--%s')
    tmp_body.append(
        ('Content-Disposition: form-data; name="file"; '
         'filename="%s"' % filename))
    tmp_body.append('Content-Type: %s' % content_type)
    tmp_body.append('')

    body.append(crlf.join(tmp_body))
    body.append(crlf)
    body.append(input_file)
    body.append(crlf)

    tmp_body = []
    for k, v in params.iteritems():
      tmp_body.append('--%s' % boundary)
      tmp_body.append(
          'Content-Disposition: form-data; name="%s"' % k)
      tmp_body.append('Content-type: text/plain; charset=utf-8')
      tmp_body.append('')
      tmp_body.append(v)

    body.append(crlf.join(tmp_body))
    body.append('%s--%s--%s' % (crlf, boundary, crlf))
    body.append(crlf)

    try:
      response = self.Do('POST', url, body=body, headers=headers)
    except:
      if close_input_file:
        input_file.close()
      raise

    if close_input_file:
      input_file.close()

    return response
dataset/ETHPy150Open google/simian/src/simian/client/client.py/HttpsClient.DoMultipart/swapped operands of `%`