#NEWLINE# def restructure( self ) : #NEWLINE# #INDENT# '@restructure\n\n        This method restructures the supplied data, into a consistent\n        dictionary format. The nested supplied dataset, is left untouched.\n\n        ' #NEWLINE# formatted_settings = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# formatted_files = [ ] #NEWLINE# try : #NEWLINE# #INDENT# for ( key , value ) in self . settings . items ( ) : #NEWLINE# #INDENT# if ( str ( type ( self . settings ) ) == self . type_web ) : #NEWLINE# #INDENT# for lvalue in self . settings . getlist ( key ) : #NEWLINE# #INDENT# if ( key . lower ( ) not in formatted_settings ) : #NEWLINE# #INDENT# formatted_settings [ key . lower ( ) ] = lvalue . lower ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type ( formatted_settings [ key . lower ( ) ] ) == unicode ) : #NEWLINE# #INDENT# formatted_settings [ key . lower ( ) ] = [ formatted_settings [ key . lower ( ) ] ] #NEWLINE# formatted_settings [ key . lower ( ) ] . append ( lvalue ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type ( formatted_settings [ key . lower ( ) ] ) == list ) : #NEWLINE# #INDENT# formatted_settings [ key . lower ( ) ] . append ( lvalue ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( str ( type ( self . settings ) ) == self . type_programmatic ) : #NEWLINE# #INDENT# formatted_settings = self . settings #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except Exception as error : #NEWLINE# #INDENT# self . list_error . append ( error ) #NEWLINE# return { #NEWLINE# #INDENT# 'data' : None , #NEWLINE# 'error' : self . list_error , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if self . dataset : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( str ( type ( value . settings ) ) == self . type_web ) : #NEWLINE# #INDENT# for file in self . dataset . getlist ( 'svm_dataset[]' ) : #NEWLINE# #INDENT# formatted_files . append ( { #NEWLINE# #INDENT# 'filename' : file . filename , #NEWLINE# 'file' : file , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# dataset = { #NEWLINE# #INDENT# 'upload_quantity' : len ( self . dataset . getlist ( 'svm_dataset[]' ) ) , #NEWLINE# 'file_upload' : formatted_files , #NEWLINE# 'json_string' : None , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( str ( type ( self . settings ) ) == self . type_programmatic ) : #NEWLINE# #INDENT# dataset = { #NEWLINE# #INDENT# 'upload_quantity' : 1 , #NEWLINE# 'file_upload' : None , #NEWLINE# 'json_string' : self . dataset , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except Exception as error : #NEWLINE# #INDENT# self . list_error . append ( error ) #NEWLINE# return { #NEWLINE# #INDENT# 'data' : None , #NEWLINE# 'error' : self . list_error , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# dataset = None #NEWLINE# #UNINDENT# data = { #NEWLINE# #INDENT# 'settings' : formatted_settings , #NEWLINE# 'dataset' : dataset , #NEWLINE# #UNINDENT# } #NEWLINE# return { #NEWLINE# #INDENT# 'data' : data , #NEWLINE# 'error' : None , #NEWLINE# #UNINDENT# }