#NEWLINE# def _convert_files( files ) : #NEWLINE# #INDENT# 'Files can be passed in a variety of formats:\n\n        * {\'file\': open("bla.f")}\n        * {\'file\': (name, open("bla.f"))}\n        * {\'file\': (name, content-type, open("bla.f"))}\n        * Anything that has iteritems method, e.g. MultiDict:\n          MultiDict([(name, open()), (name, open())]\n\n        Our goal is to standardize it to unified form of:\n\n        * [(param, (file name, content type, producer))]\n    ' #NEWLINE# if hasattr ( files , 'iteritems' ) : #NEWLINE# #INDENT# files = files . iteritems ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( files , 'items' ) : #NEWLINE# #INDENT# files = files . items ( ) #NEWLINE# #UNINDENT# #UNINDENT# for ( param , val ) in files : #NEWLINE# #INDENT# ( file_name , content_type , fobj ) = ( None , None , None ) #NEWLINE# if isinstance ( val , tuple ) : #NEWLINE# #INDENT# if ( len ( val ) == 2 ) : #NEWLINE# #INDENT# ( file_name , fobj ) = val #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( val ) == 3 ) : #NEWLINE# #INDENT# ( file_name , content_type , fobj ) = val #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# fobj = val #NEWLINE# if hasattr ( fobj , 'name' ) : #NEWLINE# #INDENT# file_name = FilePath ( fobj . name ) . basename ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not content_type ) : #NEWLINE# #INDENT# content_type = _guess_content_type ( file_name ) #NEWLINE# #UNINDENT# ( yield ( param , ( file_name , content_type , IBodyProducer ( fobj ) ) ) )