#NEWLINE# def _send_with_data( self , url , method = 'post' , output = 'json' , **kwargs ) : #NEWLINE# #INDENT# mapper = kwargs . get ( 'mapper' ) #NEWLINE# if mapper : #NEWLINE# #INDENT# del kwargs [ 'mapper' ] #NEWLINE# #UNINDENT# files = kwargs . get ( 'files' ) #NEWLINE# data = kwargs . get ( 'data' ) #NEWLINE# func = getattr ( self . session , method . lower ( ) ) #NEWLINE# req = None #NEWLINE# headers = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if data : #NEWLINE# #INDENT# headers = { #NEWLINE# #INDENT# 'content-type' : 'application/json' , #NEWLINE# #UNINDENT# } #NEWLINE# req = func ( url , headers = headers , ** kwargs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if files : #NEWLINE# #INDENT# req = func ( url , ** kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 200 <= req . status_code < 300 ) : #NEWLINE# #INDENT# if ( output is None ) : #NEWLINE# #INDENT# return req #NEWLINE# #UNINDENT# rv = getattr ( req , output ) #NEWLINE# if mapper : #NEWLINE# #INDENT# return mapper ( escape_html ( rv ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if callable ( rv ) : #NEWLINE# #INDENT# return escape_html ( rv ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# return output #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . handle_error ( req )