def prepare_post_parameters(self, post_params=None, files=None):
params = {}<EOL>if post_params:<EOL><INDENT>params.update(post_params)<EOL><DEDENT>if files:<EOL><INDENT>for k, v in iteritems(files):<EOL><INDENT>if not v:<EOL><INDENT>continue<EOL><DEDENT>with open(v, '<STR_LIT:rb>') as f:<EOL><INDENT>filename = os.path.basename(f.name)<EOL>filedata = f.read()<EOL>mimetype = mimetypes.guess_type(filename)[<NUM_LIT:0>] or '<STR_LIT>'<EOL>params[k] = tuple([filename, filedata, mimetype])<EOL><DEDENT><DEDENT><DEDENT>return params<EOL>
Builds form parameters.

:param post_params: Normal form parameters.
:param files: File parameters.
:return: Form parameters with files.