#NEWLINE# def extract_context( func , * args , **kwargs ) : #NEWLINE# #INDENT# arginfo = inspect . getargspec ( func ) #NEWLINE# arg_names = arginfo . args #NEWLINE# defaults = { arg_names . pop ( ( - 1 ) ) : kwarg for kwarg in ( arginfo . defaults or [ ] ) } #NEWLINE# computed_args = zip ( arg_names , args ) #NEWLINE# if arginfo . varargs : #NEWLINE# #INDENT# computed_args . append ( ( 'args' , list ( args [ len ( arg_names ) : ] ) ) ) #NEWLINE# #UNINDENT# if kwargs : #NEWLINE# #INDENT# defaults [ 'kwargs' ] = kwargs #NEWLINE# #UNINDENT# return dict ( computed_args , ** defaults )