def _encode_multipart_formdata(self):
def get_content_type(filename):<EOL><INDENT>"<STR_LIT>"<EOL>return mimetypes.guess_type(filename)[<NUM_LIT:0>] or '<STR_LIT>'<EOL><DEDENT>boundary = '<STR_LIT>' % (time.time())<EOL>logical_lines = []<EOL>for name, value in self.fields:<EOL><INDENT>if value is None:<EOL><INDENT>continue<EOL><DEDENT>logical_lines.append('<STR_LIT>' + boundary)<EOL>if hasattr(value, "<STR_LIT>"):<EOL><INDENT>filename = getattr(value, "<STR_LIT:name>", str(id(value))+"<STR_LIT>")<EOL>logical_lines.append('<STR_LIT>' % (<EOL>name,<EOL>os.path.basename(filename).replace("<STR_LIT:'>", '<STR_LIT:_>').replace('<STR_LIT:">', '<STR_LIT:_>')<EOL>))<EOL>logical_lines.append('<STR_LIT>' % get_content_type(filename))<EOL>logical_lines.append('<STR_LIT>')<EOL>value = value.read()<EOL><DEDENT>else:<EOL><INDENT>logical_lines.append('<STR_LIT>' % name)<EOL>logical_lines.append('<STR_LIT>')<EOL>value = fmt.to_utf8(value)<EOL><DEDENT>logical_lines.append('<STR_LIT>')<EOL>logical_lines.append(value)<EOL><DEDENT>logical_lines.append('<STR_LIT>' + boundary + '<STR_LIT>')<EOL>logical_lines.append('<STR_LIT>')<EOL>body = '<STR_LIT:\r\n>'.join(logical_lines)<EOL>content_type = '<STR_LIT>' % boundary<EOL>return content_type, body<EOL>
Encode POST body.
            Return (content_type, body) ready for httplib.HTTP instance