#NEWLINE# def getargspec( func ) : #NEWLINE# #INDENT# 'Get the argument specification of `func`.\n\n    :param func: The target.\n    :type func: a python function, built-in function or bound method\n    :rtype: (args, varargs, keywords, defaults)\n\n    It gets the argument specification by parsing documentation of the\n    function if `func` is a built-in function.\n\n    .. versionchanged:: 0.1.4\n       Remove `self` automatively if `func` is a method.\n\n    .. versionadded:: 0.1.3\n    ' #NEWLINE# if inspect . isfunction ( func ) : #NEWLINE# #INDENT# return inspect . getargspec ( func ) #NEWLINE# #UNINDENT# if inspect . ismethod ( func ) : #NEWLINE# #INDENT# argspec = inspect . getargspec ( func ) #NEWLINE# argspec [ 0 ] . pop ( 0 ) #NEWLINE# return argspec #NEWLINE# #UNINDENT# def strbetween( s , a , b ) : #NEWLINE# #INDENT# return s [ s . find ( a ) : s . rfind ( b ) ] #NEWLINE# #UNINDENT# argspecdoc = ( inspect . getdoc ( func ) or '' ) . split ( '\n' ) [ 0 ] #NEWLINE# argpart = strbetween ( argspecdoc , '(' , ')' ) #NEWLINE# args = argpart . split ( ',' ) #NEWLINE# args = ( arg . strip ( ' ()[]' ) for arg in args ) #NEWLINE# args = [ arg for arg in args if arg ] #NEWLINE# defaultpart = strbetween ( argspec , '[' , ']' ) #NEWLINE# defaultcount = len ( [ d for d in defaultpart . split ( ',' ) if d . strip ( '[]' ) ] ) #NEWLINE# return ( args , None , None , ( ( ( None , ) * defaultcount ) or None ) )