def prepare_post_parameters(self, post_params=None, files=None):
params = []<EOL>if post_params:<EOL><INDENT>params = post_params<EOL><DEDENT>if files:<EOL><INDENT>for k, v in iteritems(files):<EOL><INDENT>if not v:<EOL><INDENT>continue<EOL><DEDENT>file_names = v if type(v) is list else [v]<EOL>for n in file_names:<EOL><INDENT>with open(n, '<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.append(tuple([k, tuple([filename, filedata, mimetype])]))<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return params<EOL>
Builds form parameters.

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