;ņ :^>c@s°dddfZdZdkZdkZdfd„ƒYZd„Zedjo\dd „ZeeƒZd Gei ƒGHd Gei ƒGHd Gei ƒGHd Gei ƒGHdGndS(iis This module, Signature, contains a single class Signature. This class permits the convenient examination of the call signatures of Python callable objects. Here's some examples of its use: >>> def foo(x, y, z=-1.0, *args, **kw): ... return (x+y)**z ... >>> f = Signature(foo) >>> print 'ordinary arglist:', f.ordinary_args() ordinary arglist: ('x', 'y', 'z') >>> print 'special_args:', f.special_args() special_args: {'keyword': 'kw', 'positional': 'args'} >>> print 'full_arglist:', f.full_arglist() full_arglist: ['x', 'y', 'z', 'args', 'kw'] >>> print 'defaults:', f.defaults() defaults: {'z': -1.0} >>> print 'signature:', str(f) signature: foo(x, y, z=-1.0, *args, **kw) The methods of the Signature class are documented below: o Signature(func) Arguments: func -- this is any callable object written in Python Returns: a Signature instance Raises: TypeError, ValueError Behavior: The Signature constructor returns a Signature instance for the callable object func. If func is not callable, then a TypeError is raised. If it is callable, but can't be handled, then a ValueError is raised. (At the moment, the latter category are any C builtins.) o Signature.ordinary_args() Returns: A tuple of strings containing the names of all 'normal' arguments. Behavior: If the callable object has no arguments, the empty tuple is returned. The definition of 'normal' includes explicit keyword arguments and the 'self' argument for methods, but does not include the special arguments specified with the '*' or '**' syntax. o Signature.special_args() Returns: A dictionary with the names of the special arguments. Behavior: This method returns a dictionary of 0, 1, or 2 arguments. An entry with a key of 'positional' has the name of the '*'-argument as its value, and an entry with a key of 'keyword' has the name of the '**'-argument as its value. If the dictionary is empty, then there are no special arguments. o Signature.full_arglist() Returns: A list of all the arguments to the function, whether special or not. Behavior: If there are no special arguments, Signature.full_arglist()'s returns a list with the same elements as Signature.ordinary_args(). If there are are special arguments, they appended to the end of the list, with the '*'-argument preceding the '**'-argument. No asterisks are added to the argument names in the returned list. o Signature.defaults() Returns: A dictionary containing the argument names (as a string) as the keys and the default objects as values. Behavior: If there are no arguments with default values, then an empty dictionary is returned. The special arguments specified with the '*' and '**' syntax are not considered. o Signature.__str__() Returns: A string that should resemble the function or method declaration. Behavior: While it's impossible to exactly match the actual declaration, in most cases this should look pretty close. Ns SignaturecBsJtZdZdZd„Zd„Zd„Zd„Zd„Zd„Z RS( NiicCs+t|ƒ|_t|ƒ\|_|_dS(N(stypesfuncsselfs_getcodesname(sselfsfunc((s[/mnt/gmirror/ports/devel/boaconstructor/work/boa-constructor-0.4.4/ExternalLib/Signature.pys__init__pscCs'|iii}|iiid|!SdS(Ni(sselfsfuncs func_codes co_argcountsns co_varnames(sselfsn((s[/mnt/gmirror/ports/devel/boaconstructor/work/boa-constructor-0.4.4/ExternalLib/Signature.pys ordinary_argssscCs|iii}h}|iii|i|iB@oe|iii ||dx;tdt |ƒd dƒD]}|||||½s(shasattrsfs__name__s__init__sim_func(sf((s[/mnt/gmirror/ports/devel/boaconstructor/work/boa-constructor-0.4.4/ExternalLib/Signature.pys class_get¹sstype %s not supported yet.s%object %s of type %s is not callable.N(s method_gets function_gets instance_gets class_getstypessUnboundMethodTypes MethodTypes FunctionTypes InstanceTypes ClassTypescodedictstypesfsKeyErrorscallables ValueErrors TypeError(sfs function_gets instance_gets class_gets method_getscodedict((s[/mnt/gmirror/ports/devel/boaconstructor/work/boa-constructor-0.4.4/ExternalLib/Signature.pys_getcode©s    B s__main__f-1.0cOs|||SdS(N(sxsysz(sxsyszsargsskw((s[/mnt/gmirror/ports/devel/boaconstructor/work/boa-constructor-0.4.4/ExternalLib/Signature.pysfooĪssordinary arglist:s special_args:s full_arglist:s defaults:s signature:( s __version__s__doc__stypessstrings Signatures_getcodes__name__sfoosfs ordinary_argss special_argss full_arglistsdefaults(sfoosstringsfs_getcodes Signatures __version__s__doc__stypes((s[/mnt/gmirror/ports/devel/boaconstructor/work/boa-constructor-0.4.4/ExternalLib/Signature.pys?sf? $