#NEWLINE# @ staticmethod #NEWLINE# def _output_curl_command( resp , file ) : #NEWLINE# #INDENT# 'Write the request as a curl command to the given file.' #NEWLINE# if ( not file ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# req = resp . request #NEWLINE# command = "curl -X %(method)s -H %(headers)s -d '%(data)s' '%(url)s'\n" #NEWLINE# headers = ' -H ' . join ( [ ( "'%s: %s'" % ( k , v ) ) for ( k , v ) in req . headers . items ( ) ] ) #NEWLINE# args = { #NEWLINE# #INDENT# 'method' : req . method , #NEWLINE# 'url' : req . url , #NEWLINE# 'data' : ( req . body or '' ) , #NEWLINE# 'headers' : headers , #NEWLINE# #UNINDENT# } #NEWLINE# file . write ( ( command % args ) ) #NEWLINE# file . write ( ( ( ( ( '\n' + ( '*' * 35 ) ) + ' GOT ' ) + ( '*' * 35 ) ) + '\n' ) ) #NEWLINE# file . write ( resp . text ) #NEWLINE# file . write ( ( ( ( ( '\n' + ( '*' * 35 ) ) + ' END ' ) + ( '*' * 35 ) ) + '\n\n' ) )