

def encode_multipart(vars, files=None, boundary=None):
    '\n    Encode a set of variables and/or files into a ``multipart/form-data``\n    request body, and returns a list of strings and files that can be sent to\n    the server, along with the used boundary.\n\n    =========  ============\n    Argument   Description\n    =========  ============\n    vars       A dictionary of variables to encode.\n    files      *Optional.* A dictionary of tuples of ``(filename, data)`` to encode.\n    boundary   *Optional.* The boundary string to use when encoding, if for any reason the default string is unacceptable.\n    =========  ============\n    '
    if (boundary is None):
        boundary = '-----pants-----PANTS-----pants$'
    out = []
    for (k, v) in vars.iteritems():
        out.append(('--%s%sContent-Disposition: form-data; name="%s"%s%s%s' % (boundary, CRLF, k, DOUBLE_CRLF, v, CRLF)))
    if files:
        for (k, v) in files.iteritems():
            if isinstance(v, (list, tuple)):
                (fn, v) = v
            else:
                fn = get_filename(v)
                if (not fn):
                    fn = k
            out.append(('--%s%sContent-Disposition: form-data; name="%s"; filename="%s"%sContent-Type: %s%sContent-Transfer-Encoding: binary%s' % (boundary, CRLF, k, fn, CRLF, content_type(fn), CRLF, DOUBLE_CRLF)))
            out.append(v)
            fn.append(CRLF)
    out.append(('--%s--%s' % (boundary, CRLF)))
    return (boundary, out)

dataset/ETHPy150Open ecdavis/pants/pants/http/utils.py encode_multipart/VarMisuse@183/484 `out`->`fn`