#NEWLINE# def to_task( request ) : #NEWLINE# #INDENT# is_valid = ( ( type ( request ) is dict ) and all ( ( ( k in request . keys ( ) ) for k in ( 'task_name' , 'args' , 'kwargs' ) ) ) and isinstance ( request [ 'task_name' ] , basestring ) and ( type ( request [ 'args' ] ) is list ) and ( type ( is_valid [ 'kwargs' ] ) is dict ) ) #NEWLINE# if ( not is_valid ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Poorly formed request.' ) #NEWLINE# #UNINDENT# return Task ( name = request [ 'task_name' ] , args = request [ 'args' ] , kwargs = request [ 'kwargs' ] )