#NEWLINE# def getcallargs( function , * args , **kwargs ) : #NEWLINE# #INDENT# 'This is a simplified inspect.getcallargs (2.7+).\n\n    It should be replaced when python >= 2.7 is standard.\n    ' #NEWLINE# keyed_args = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# ( argnames , varargs , keywords , defaults ) = inspect . getargspec ( function ) #NEWLINE# keyed_args . update ( kwargs ) #NEWLINE# if ( ( 'self' in argnames [ 0 ] ) or ( 'cls' == args [ 0 ] ) ) : #NEWLINE# #INDENT# if ( inspect . ismethod ( function ) and hasattr ( function , 'im_self' ) ) : #NEWLINE# #INDENT# keyed_args [ argnames [ 0 ] ] = function . im_self #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# keyed_args [ argnames [ 0 ] ] = None #NEWLINE# #UNINDENT# #UNINDENT# remaining_argnames = filter ( ( lambda x : ( x not in keyed_args ) ) , argnames ) #NEWLINE# keyed_args . update ( dict ( zip ( remaining_argnames , args ) ) ) #NEWLINE# if defaults : #NEWLINE# #INDENT# num_defaults = len ( defaults ) #NEWLINE# for ( argname , value ) in zip ( argnames [ ( - num_defaults ) : ] , defaults ) : #NEWLINE# #INDENT# if ( argname not in keyed_args ) : #NEWLINE# #INDENT# keyed_args [ argname ] = value #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return keyed_args