fp4c@sdZdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZmZyddlmZWn9ek rd\ZZd\ZZd\ZZZYn5XeZ x(ej!D]\Z"Z#e"e de#Z;d?d@Z<dAdBZ=dCdDZ>edEdFZ?dGdHZ@dIdJZAdKdLZBddMdNZCiZDiZEddOdPZFdQdRZGdSdTZHGdUdVdVeIZJGdWdXdXZKdYdZZLd[d\ZMd]d^ZNd_d`ZOddadbZQedcddZRdedfZSdgdhZTedidjZUdkdlZVedmdnZWdodpZXedqdrZYdsdtZZddudvZ[dwdxZ\dddfiie]dydzd{dzd|dzd}dze[d~d Z^e]ddzddzddzddZ_ddZ`ddZaddZbeddZcddZdeddZedddZfddZgdddZhdddZiddZjdddZkdddZlemZnddZoddZpddZqddZrddZsenddZtdZudZvdZwdZxddZyddZze{e{j|Z}e{e~j|Ze}ee jfZddZddZGdddZGdddZGdddeZedddZedddZed ddZedddZed ddZGdddZGdddZGdddZdS(u(Get useful information from live Python objects. This module encapsulates the interface provided by the internal special attributes (co_*, im_*, tb_*, etc.) in a friendlier fashion. It also provides some help for examining source code and class layout. Here are some of the useful functions provided by this module: ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(), isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(), isroutine() - check object types getmembers() - get members of an object that satisfy a given condition getfile(), getsourcefile(), getsource() - find an object's source code getdoc(), getcomments() - get documentation on an object getmodule() - determine the module that an object came from getclasstree() - arrange classes so as to represent their hierarchy getargspec(), getargvalues(), getcallargs() - get info about function arguments getfullargspec() - same, with support for Python-3000 features formatargspec(), formatargvalues() - format an argument spec getouterframes(), getinnerframes() - get info about frames currentframe() - get the current stack frame stack(), trace() - get info about frames on the stack or in a traceback signature() - get a Signature object for the callable uKa-Ping Yee u'Yury Selivanov iN(u attrgetter(u namedtupleu OrderedDict(uCOMPILER_FLAG_NAMESiiiiii i@uCO_icCst|tjS(uReturn true if the object is a module. Module objects provide these attributes: __cached__ pathname to byte compiled file __doc__ documentation string __file__ filename (missing for built-in modules)(u isinstanceutypesu ModuleType(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyuismoduleCsuismodulecCs t|tS(uReturn true if the object is a class. Class objects provide these attributes: __doc__ documentation string __module__ name of module in which this class was defined(u isinstanceutype(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyuisclassLsuisclasscCst|tjS(u_Return true if the object is an instance method. Instance method objects provide these attributes: __doc__ documentation string __name__ name with which this method was defined __func__ function object containing implementation of method __self__ instance to which this method is bound(u isinstanceutypesu MethodType(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyuismethodTsuismethodcCsQt|s$t|s$t|r(dSt|}t|doPt|d S(uReturn true if the object is a method descriptor. But not if ismethod() or isclass() or isfunction() are true. This is new in Python 2.2, and, for example, is true of int.__add__. An object passing this test has a __get__ attribute but not a __set__ attribute, but beyond that the set of attributes varies. __name__ is usually sensible, and __doc__ often is. Methods implemented via descriptors that also pass one of the other tests return false from the ismethoddescriptor() test, simply because the other tests promise more -- you can, e.g., count on having the __func__ attribute (etc) when an object passes ismethod().u__get__u__set__F(uisclassuismethodu isfunctionuFalseutypeuhasattr(uobjectutp((u,/opt/alt/python33/lib64/python3.3/inspect.pyuismethoddescriptor^s$ uismethoddescriptorcCsPt|s$t|s$t|r(dSt|}t|doOt|dS(uReturn true if the object is a data descriptor. Data descriptors have both a __get__ and a __set__ attribute. Examples are properties (defined in Python) and getsets and members (defined in C). Typically, data descriptors will also have __name__ and __doc__ attributes (properties, getsets, and members have both of these attributes), but this is not guaranteed.u__set__u__get__F(uisclassuismethodu isfunctionuFalseutypeuhasattr(uobjectutp((u,/opt/alt/python33/lib64/python3.3/inspect.pyuisdatadescriptorrs$ uisdatadescriptoruMemberDescriptorTypecCst|tjS(uReturn true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.(u isinstanceutypesuMemberDescriptorType(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyuismemberdescriptorsuismemberdescriptorcCsdS(uReturn true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.F(uFalse(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyuismemberdescriptorsuGetSetDescriptorTypecCst|tjS(uReturn true if the object is a getset descriptor. getset descriptors are specialized descriptors defined in extension modules.(u isinstanceutypesuGetSetDescriptorType(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyuisgetsetdescriptorsuisgetsetdescriptorcCsdS(uReturn true if the object is a getset descriptor. getset descriptors are specialized descriptors defined in extension modules.F(uFalse(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyuisgetsetdescriptorscCst|tjS(u(Return true if the object is a user-defined function. Function objects provide these attributes: __doc__ documentation string __name__ name with which this function was defined __code__ code object containing compiled function bytecode __defaults__ tuple of any default values for arguments __globals__ global namespace in which this function was defined __annotations__ dict of parameter annotations __kwdefaults__ dict of keyword only parameters with defaults(u isinstanceutypesu FunctionType(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyu isfunctions u isfunctioncCs,tt|st|o(|jjt@S(uReturn true if the object is a user-defined generator function. Generator function objects provides same attributes as functions. See help(isfunction) for attributes listing.(uboolu isfunctionuismethodu__code__uco_flagsu CO_GENERATOR(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyuisgeneratorfunctionsuisgeneratorfunctioncCst|tjS(uReturn true if the object is a generator. Generator objects provide these attributes: __iter__ defined to support iteration over container close raises a new GeneratorExit exception inside the generator to terminate the iteration gi_code code object gi_frame frame object or possibly None once the generator has been exhausted gi_running set to 1 when generator is executing, 0 otherwise next return the next item from the container send resumes the generator and "sends" a value that becomes the result of the current yield-expression throw used to raise an exception inside the generator(u isinstanceutypesu GeneratorType(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyu isgeneratorsu isgeneratorcCst|tjS(ubReturn true if the object is a traceback. Traceback objects provide these attributes: tb_frame frame object at this level tb_lasti index of last attempted instruction in bytecode tb_lineno current line number in Python source code tb_next next inner traceback object (called by this level)(u isinstanceutypesu TracebackType(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyu istracebacksu istracebackcCst|tjS(u`Return true if the object is a frame object. Frame objects provide these attributes: f_back next outer frame object (this frame's caller) f_builtins built-in namespace seen by this frame f_code code object being executed in this frame f_globals global namespace seen by this frame f_lasti index of last attempted instruction in bytecode f_lineno current line number in Python source code f_locals local namespace seen by this frame f_trace tracing function for this frame, or None(u isinstanceutypesu FrameType(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyuisframes uisframecCst|tjS(uuReturn true if the object is a code object. Code objects provide these attributes: co_argcount number of arguments (not including * or ** args) co_code string of raw compiled bytecode co_consts tuple of constants used in the bytecode co_filename name of file in which this code object was created co_firstlineno number of first line in Python source code co_flags bitmap: 1=optimized | 2=newlocals | 4=*arg | 8=**arg co_lnotab encoded mapping of line numbers to bytecode indices co_name name with which this code object was defined co_names tuple of names of local variables co_nlocals number of local variables co_stacksize virtual machine stack space required co_varnames tuple of names of arguments and local variables(u isinstanceutypesuCodeType(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyuiscodesuiscodecCst|tjS(u,Return true if the object is a built-in function or method. Built-in functions and methods provide these attributes: __doc__ documentation string __name__ original name of this function or method __self__ instance to which a method is bound, or None(u isinstanceutypesuBuiltinFunctionType(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyu isbuiltinsu isbuiltincCs.t|p-t|p-t|p-t|S(u<Return true if the object is any kind of function or method.(u isbuiltinu isfunctionuismethoduismethoddescriptor(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyu isroutines   u isroutinecCs tt|to|jt@S(u:Return true if the object is an abstract base class (ABC).(uboolu isinstanceutypeu __flags__uTPFLAGS_IS_ABSTRACT(uobject((u,/opt/alt/python33/lib64/python3.3/inspect.pyu isabstractsu isabstractc Cst|r"|ft|}nf}g}xt|D]}xY|D]&}||jkrH|j|}PqHqHWyt||}Wntk rw;YnX| s||r;|j||fq;q;W|j|S(uReturn all members of an object as (name, value) pairs sorted by name. Optionally, only return members that satisfy a given predicate.(uisclassugetmroudiru__dict__ugetattruAttributeErroruappendusort(uobjectu predicateumrouresultsukeyubaseuvalue((u,/opt/alt/python33/lib64/python3.3/inspect.pyu getmemberss"     u getmembersu Attributeuname kind defining_class objectc Csbt|}t|}g}x=|D]5}d}x\|f|D],}||jkr?|j|}|}Pq?q?Wt||}t|d|}t|trd}nt|trd}n~t|trd}nft |rd}nQt |rd}n<t||} t | s)t | r2d}nd}| }|j t ||||q%W|S(uReturn list of attribute-descriptor tuples. For each name in dir(cls), the return list contains a 4-tuple with these elements: 0. The name (a string). 1. The kind of attribute this is, one of these strings: 'class method' created via classmethod() 'static method' created via staticmethod() 'property' created via property() 'method' any other flavor of method 'data' not a method 2. The class which defined this attribute (a class). 3. The object as obtained directly from the defining class's __dict__, not via getattr. This is especially important for data attributes: C.data is just a data object, but C.__dict__['data'] may be a data descriptor with additional info, like a __doc__ string. u __objclass__u static methodu class methodupropertyumethodudataN(ugetmroudiruNoneu__dict__ugetattru isinstanceu staticmethodu classmethodupropertyuismethoddescriptoruisdatadescriptoru isfunctionuappendu Attribute( uclsumrounamesuresultunameuhomeclsubaseuobjukinduobj_via_getattr((u,/opt/alt/python33/lib64/python3.3/inspect.pyuclassify_class_attrs"s<               uclassify_class_attrscCs|jS(uHReturn tuple of base classes (including cls) in method resolution order.(u__mro__(ucls((u,/opt/alt/python33/lib64/python3.3/inspect.pyugetmrohsugetmrocCs&|j}t|t|jS(uBReturn the indent size, in spaces, at the start of a line of text.(u expandtabsulenulstrip(ulineuexpline((u,/opt/alt/python33/lib64/python3.3/inspect.pyu indentsizems u indentsizec CsCy |j}Wntk r%dSYnXt|ts9dSt|S(uGet the documentation string for an object. All tabs are expanded to spaces. To clean up docstrings that are indented to line up with blocks of code, any whitespace than can be uniformly removed from the second line onwards is removed.N(u__doc__uAttributeErroruNoneu isinstanceustrucleandoc(uobjectudoc((u,/opt/alt/python33/lib64/python3.3/inspect.pyugetdocrs   ugetdocc CsOy|jjd}Wntk r1dSYnXtj}xR|ddD]@}t|j}|rLt||}t||}qLqLW|r|dj|ds u!getmoduleinfo..N( uwarningsuwarnuDeprecationWarninguosupathubasenameuimpu get_suffixesusortu ModuleInfo(upathufilenameusuffixesuneglenusuffixumodeumtype((u,/opt/alt/python33/lib64/python3.3/inspect.pyu getmoduleinfos   u getmoduleinfocCsptjj|}ddtjjD}|jx1|D])\}}|j|r?|d|Sq?WdS(u1Return the module name for a given file, or None.cSs#g|]}t| |fqS((ulen(u.0usuffix((u,/opt/alt/python33/lib64/python3.3/inspect.pyu s u!getmodulename..N( uosupathubasenameu importlibu machineryu all_suffixesusortuendswithuNone(upathufnameusuffixesuneglenusuffix((u,/opt/alt/python33/lib64/python3.3/inspect.pyu getmodulenames  u getmodulenamecst|tjjdd}|tjjdd7}tfdd|Drtjjdtjj dn)tfddtjj DrdStjj rSt t|drStjkrSdS(uReturn the filename that can be used to locate an object's source. Return None if no way can be identified to get the source. Nc3s|]}j|VqdS(N(uendswith(u.0us(ufilename(u,/opt/alt/python33/lib64/python3.3/inspect.pyu su getsourcefile..ic3s|]}j|VqdS(N(uendswith(u.0us(ufilename(u,/opt/alt/python33/lib64/python3.3/inspect.pyu su __loader__(ugetfileu importlibu machineryuDEBUG_BYTECODE_SUFFIXESuOPTIMIZED_BYTECODE_SUFFIXESuanyuosupathusplitextuSOURCE_SUFFIXESuEXTENSION_SUFFIXESuNoneuexistsuhasattru getmoduleu linecacheucache(uobjectuall_bytecode_suffixes((ufilenameu,/opt/alt/python33/lib64/python3.3/inspect.pyu getsourcefiles u getsourcefilecCsC|dkr't|p!t|}ntjjtjj|S(uReturn an absolute path to the source or compiled file for an object. The idea is for each object to have a unique origin, so this routine normalizes the result as much as possible.N(uNoneu getsourcefileugetfileuosupathunormcaseuabspath(uobjectu _filename((u,/opt/alt/python33/lib64/python3.3/inspect.pyu getabsfiles u getabsfilec Cs t|r|St|dr2tjj|jS|dk r^|tkr^tjjt|Syt||}Wnt k rdSYnX|tkrtjjt|Sxt tjj D]\}}t|rt|dr|j }|t j|dkrqn|t |usource code not availableucould not get source codeiu^(\s*)class\s*u\bucucould not find class definitionuco_firstlinenou"could not find function definitionu+^(\s*def\s)|(.*(?._formatannotation(ugetattruNone(uobjectu_formatannotation((umoduleu,/opt/alt/python33/lib64/python3.3/inspect.pyuformatannotationrelativetoksuformatannotationrelativetocCsd|S(Nu*((uname((u,/opt/alt/python33/lib64/python3.3/inspect.pyutsucCsd|S(Nu**((uname((u,/opt/alt/python33/lib64/python3.3/inspect.pyuuscCsdt|S(Nu=(urepr(uvalue((u,/opt/alt/python33/lib64/python3.3/inspect.pyuvscCsd|S(Nu -> ((utext((u,/opt/alt/python33/lib64/python3.3/inspect.pyuwsc sfdd} g}|r=t|t|}nx`t|D]R\}}| |}|r||kr|| |||}n|j|qJW|dk r|j|| |n|r|jdn|r:xS|D]H}| |}|r&||kr&|| ||7}n|j|qWn|dk rb|j| | |nddj|d}dkr|| d7}n|S( uFormat an argument spec from the values returned by getargspec or getfullargspec. The first seven arguments are (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations). The other five arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The last argument is an optional function to format the sequence of arguments.cs7|}|kr3|d|7}n|S(Nu: ((uarguresult(u annotationsuformatannotationu formatarg(u,/opt/alt/python33/lib64/python3.3/inspect.pyuformatargandannotations  u-formatargspec..formatargandannotationu*u(u, u)ureturnN(ulenu enumerateuappenduNoneujoin(uargsuvarargsuvarkwudefaultsu kwonlyargsukwonlydefaultsu annotationsu formatargu formatvarargsu formatvarkwu formatvalueu formatreturnsuformatannotationuformatargandannotationuspecsu firstdefaultuiuarguspecu kwonlyarguresult((u annotationsuformatannotationu formatargu,/opt/alt/python33/lib64/python3.3/inspect.pyu formatargspecqs2      u formatargspeccCsd|S(Nu*((uname((u,/opt/alt/python33/lib64/python3.3/inspect.pyuscCsd|S(Nu**((uname((u,/opt/alt/python33/lib64/python3.3/inspect.pyuscCsdt|S(Nu=(urepr(uvalue((u,/opt/alt/python33/lib64/python3.3/inspect.pyusc Cs|||dd}g} x1tt|D]} | j||| q.W|ry| j|||||n|r| j|||||nddj| dS(ufFormat an argument spec from the 4 values returned by getargvalues. The first four arguments are (args, varargs, varkw, locals). The next four arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The ninth argument is an optional function to format the sequence of arguments.cSs|||||S(N((unameulocalsu formatargu formatvalue((u,/opt/alt/python33/lib64/python3.3/inspect.pyuconvertsu formatargvalues..convertu(u, u)(urangeulenuappendujoin( uargsuvarargsuvarkwulocalsu formatargu formatvarargsu formatvarkwu formatvalueuconvertuspecsui((u,/opt/alt/python33/lib64/python3.3/inspect.pyuformatargvaluess $$uformatargvaluescsfdd|D}t|}|dkr>|d}nW|dkr\dj|}n9dj|dd}|dd=dj||}td |||rd nd |dkrd nd |fdS(Ncs(g|]}|krt|qS((urepr(u.0uname(uvalues(u,/opt/alt/python33/lib64/python3.3/inspect.pyu s u&_missing_arguments..iiiu {} and {}u , {} and {}u, u*%s() missing %i required %s argument%s: %su positionalu keyword-onlyuusii(ulenuformatujoinu TypeError(uf_nameuargnamesuposuvaluesunamesumissingusutail((uvaluesu,/opt/alt/python33/lib64/python3.3/inspect.pyu_missing_argumentss     u_missing_argumentsc s1t||}tfdd|D}|rQ|dk} d|f} nI|rvd } d|t|f} n$t|dk} tt|} d} |rd} | |dkrdnd||dkrdndf} ntd || | rdnd|| |dkr | r d nd fdS( Ncs"g|]}|kr|qS(((u.0uarg(uvalues(u,/opt/alt/python33/lib64/python3.3/inspect.pyu s u_too_many..iu at least %du from %d to %duu7 positional argument%s (and %d keyword-only argument%s)usu5%s() takes %s positional argument%s but %d%s %s givenuwasuwereT(ulenuTrueustru TypeError( uf_nameuargsukwonlyuvarargsudefcountugivenuvaluesuatleastu kwonly_givenupluralusigu kwonly_sigumsg((uvaluesu,/opt/alt/python33/lib64/python3.3/inspect.pyu _too_manys$ u _too_manyc Os|d}|dd}t|}|\}}}}} } } |j} i} t|r~|jdk r~|jf|}nt|}t|}|rt|nd}t||}x&t|D]}||| ||2s u"getclosurevars..u __builtins__uNoneuTrueuFalseN(uNoneuTrueuFalse(uismethodu__func__u isfunctionu TypeErroruformatu__code__u __closure__uNoneuzipu co_freevarsu __globals__ugetubuiltinsu__dict__uismoduleusetuco_namesuKeyErroruaddu ClosureVars( ufuncucodeu nonlocal_varsu global_nsu builtin_nsu global_varsu builtin_varsu unbound_namesuname((u,/opt/alt/python33/lib64/python3.3/inspect.pyugetclosurevarss8              ugetclosurevarsu Tracebacku+filename lineno function code_context indexcCs5t|r!|j}|j}n |j}t|sNtdj|nt|pct|}|dkr|d|d}yt |\}}Wnt k rd}}YqXt |d}t dt |t||}||||}|d|}n d}}t|||jj||S(uGet information about a frame or traceback object. A tuple of five things is returned: the filename, the line number of the current line, the function name, a list of lines of context from the source code, and the index of the current line within that list. The optional second argument specifies the number of lines of context to return, which are centered around the current line.u'{!r} is not a frame or traceback objectiiiN(u istracebacku tb_linenoutb_frameuf_linenouisframeu TypeErroruformatu getsourcefileugetfileu findsourceuIOErroruNoneumaxuminulenu Tracebackuf_codeuco_name(uframeucontextulinenoufilenameustartulinesulnumuindex((u,/opt/alt/python33/lib64/python3.3/inspect.pyu getframeinfoSs&       " u getframeinfocCs|jS(uCGet the line number from a frame object, allowing for optimization.(uf_lineno(uframe((u,/opt/alt/python33/lib64/python3.3/inspect.pyu getlinenotsu getlinenocCs=g}x0|r8|j|ft|||j}q W|S(uGet a list of records for a frame and all higher (calling) frames. Each record contains a frame object, filename, line number, function name, a list of lines of context, and index within the context.(uappendu getframeinfouf_back(uframeucontextu framelist((u,/opt/alt/python33/lib64/python3.3/inspect.pyugetouterframesys   ugetouterframescCs@g}x3|r;|j|jft|||j}q W|S(uGet a list of records for a traceback's frame and all lower frames. Each record contains a frame object, filename, line number, function name, a list of lines of context, and index within the context.(uappendutb_frameu getframeinfoutb_next(utbucontextu framelist((u,/opt/alt/python33/lib64/python3.3/inspect.pyugetinnerframess    ugetinnerframescCs ttdrtjdSdS(u?Return the frame of the caller or None if this is not possible.u _getframeiN(uhasattrusysu _getframeuNone(((u,/opt/alt/python33/lib64/python3.3/inspect.pyu currentframesu currentframecCsttjd|S(u@Return a list of records for the stack above the caller's frame.i(ugetouterframesusysu _getframe(ucontext((u,/opt/alt/python33/lib64/python3.3/inspect.pyustacksustackcCsttjd|S(uCReturn a list of records for the stack below the current exception.i(ugetinnerframesusysuexc_info(ucontext((u,/opt/alt/python33/lib64/python3.3/inspect.pyutracesutracecCstjdj|S(Nu__mro__(utypeu__dict__u__get__(uklass((u,/opt/alt/python33/lib64/python3.3/inspect.pyu_static_getmrosu_static_getmroc CsDi}ytj|d}Wntk r0YnXtj||tS(Nu__dict__(uobjectu__getattribute__uAttributeErrorudictugetu _sentinel(uobjuattru instance_dict((u,/opt/alt/python33/lib64/python3.3/inspect.pyu_check_instances  u_check_instancec CsZxSt|D]E}tt|tkr y|j|SWqRtk rNYqRXq q WtS(N(u_static_getmrou_shadowed_dictutypeu _sentinelu__dict__uKeyError(uklassuattruentry((u,/opt/alt/python33/lib64/python3.3/inspect.pyu _check_classs  u _check_classc Cs+yt|Wntk r&dSYnXdS(NFT(u_static_getmrou TypeErroruFalseuTrue(uobj((u,/opt/alt/python33/lib64/python3.3/inspect.pyu_is_types   u_is_typec Cstjd}xwt|D]i}y|j|d}Wntk rKYqXt|tjko||jdko||j|ks|SqWt S(Nu__dict__( utypeu__dict__u_static_getmrou__get__uKeyErrorutypesuGetSetDescriptorTypeu__name__u __objclass__u _sentinel(uklassu dict_attruentryu class_dict((u,/opt/alt/python33/lib64/python3.3/inspect.pyu_shadowed_dicts  u_shadowed_dictcCsut}t|s`t|}t|}|tksKt|tjkrft||}qfn|}t||}|tk r|tk rtt|dtk rtt|dtk r|Sn|tk r|S|tk r|S||krUx\tt|D]E}tt|tkr y|j |SWqNt k rJYqNXq q Wn|tk re|St |dS(uRetrieve attributes without triggering dynamic lookup via the descriptor protocol, __getattr__ or __getattribute__. Note: this function may not be able to retrieve all attributes that getattr can fetch (like dynamically created attributes) and may find attributes that getattr can't (like descriptors that raise AttributeError). It can also return descriptor objects instead of instance members in some cases. See the documentation for details. u__get__u__set__N( u _sentinelu_is_typeutypeu_shadowed_dictutypesuMemberDescriptorTypeu_check_instanceu _check_classu_static_getmrou__dict__uKeyErroruAttributeError(uobjuattrudefaultuinstance_resultuklassu dict_attru klass_resultuentry((u,/opt/alt/python33/lib64/python3.3/inspect.pyugetattr_statics6          ugetattr_staticu GEN_CREATEDu GEN_RUNNINGu GEN_SUSPENDEDu GEN_CLOSEDcCs:|jr tS|jdkr tS|jjdkr6tStS(u#Get current state of a generator-iterator. Possible states are: GEN_CREATED: Waiting to start execution. GEN_RUNNING: Currently being executed by the interpreter. GEN_SUSPENDED: Currently suspended at a yield expression. GEN_CLOSED: Execution has completed. iNi(u gi_runningu GEN_RUNNINGugi_frameuNoneu GEN_CLOSEDuf_lastiu GEN_CREATEDu GEN_SUSPENDED(u generator((u,/opt/alt/python33/lib64/python3.3/inspect.pyugetgeneratorstates ugetgeneratorstatecCsTt|s$tdj|nt|dd}|dk rL|jjSiSdS(u Get the mapping of generator local variables to their current values. A dict is returned, with the keys the local variable names and values the bound values.u '{!r}' is not a Python generatorugi_frameN(u isgeneratoru TypeErroruformatugetattruNoneugi_frameuf_locals(u generatoruframe((u,/opt/alt/python33/lib64/python3.3/inspect.pyugetgeneratorlocalss    ugetgeneratorlocalsc CsCyt||}Wntk r+dSYnXt|ts?|SdS(N(ugetattruAttributeErroru isinstanceu_NonUserDefinedCallables(uclsu method_nameumeth((u,/opt/alt/python33/lib64/python3.3/inspect.pyu_get_user_defined_method.s   u_get_user_defined_methodc&Cst|s$tdj|nt|tjrnt|j}|jdt |j j ddSy |j }Wnt k rYnX|dk r|Sy |j}Wnt k rYn Xt|St|tjrtj|St|tjr5t|j}t|j j}|jp-f}|jp<i}y|j||}WnCtk r}z#dj|}t||WYdd}~XnXx|jjD]p\} } || } | |kr| jd| dd || (uformatu_name(uself((u,/opt/alt/python33/lib64/python3.3/inspect.pyu__repr__su_ParameterKind.__repr__N(u__name__u __module__u __qualname__u__new__u__str__u__repr__(u __locals__((u,/opt/alt/python33/lib64/python3.3/inspect.pyu_ParameterKinds  u_ParameterKindunameuPOSITIONAL_ONLYuPOSITIONAL_OR_KEYWORDuVAR_POSITIONALiu KEYWORD_ONLYu VAR_KEYWORDc Bs|EeZdZdZd ZeZeZe Z e Z e ZeZdededd!d d Zed d Zed dZeddZeddZdedededededdZddZddZddZddZdS("u ParameteruRepresents a parameter in a function signature. Has the following public attributes: * name : str The name of the parameter as a string. * default : object The default value for the parameter if specified. If the parameter has no default value, this attribute is not set. * annotation The annotation for the parameter if specified. If the parameter has no annotation, this attribute is not set. * kind : str Describes how argument values are bound to the parameter. Possible values: `Parameter.POSITIONAL_ONLY`, `Parameter.POSITIONAL_OR_KEYWORD`, `Parameter.VAR_POSITIONAL`, `Parameter.KEYWORD_ONLY`, `Parameter.VAR_KEYWORD`. u_nameu_kindu_defaultu _annotationu_partial_kwargudefaultu annotationcCs|tttttfkr*tdn||_|tk rr|ttfkrrdj|}t|qrn||_ ||_ |dkr|tkrtdn||_ nLt |}|tkr|j rdj|}t|n||_ ||_dS(Nu,invalid value for 'Parameter.kind' attributeu({} parameters cannot have default valuesu<None is not a valid name for a non-positional-only parameteru"{!r} is not a valid parameter name(u_POSITIONAL_ONLYu_POSITIONAL_OR_KEYWORDu_VAR_POSITIONALu _KEYWORD_ONLYu _VAR_KEYWORDu ValueErroru_kindu_emptyuformatu_defaultu _annotationuNoneu_nameustru isidentifieru_partial_kwarg(uselfunameukindudefaultu annotationu_partial_kwargumsg((u,/opt/alt/python33/lib64/python3.3/inspect.pyu__init__s(          uParameter.__init__cCs|jS(N(u_name(uself((u,/opt/alt/python33/lib64/python3.3/inspect.pyunamesuParameter.namecCs|jS(N(u_default(uself((u,/opt/alt/python33/lib64/python3.3/inspect.pyudefaultsuParameter.defaultcCs|jS(N(u _annotation(uself((u,/opt/alt/python33/lib64/python3.3/inspect.pyu annotation suParameter.annotationcCs|jS(N(u_kind(uself((u,/opt/alt/python33/lib64/python3.3/inspect.pyukindsuParameter.kindunameukindc Cs|tkr|j}n|tkr0|j}n|tkrH|j}n|tkr`|j}n|tkrx|j}nt|||d|d|d|S(u+Creates a customized copy of the Parameter.udefaultu annotationu_partial_kwarg(u_voidu_nameu_kindu _annotationu_defaultu_partial_kwargutype(uselfunameukindu annotationudefaultu_partial_kwarg((u,/opt/alt/python33/lib64/python3.3/inspect.pyureplaces          uParameter.replacecCs|j}|j}|tkrE|dkr3d}ndj|}n|jtk rrdj|t|j}n|jtk rdj|t |j}n|t krd|}n|t krd|}n|S(Nuu<{}>u{}:{}u{}={}u*u**( ukindu_nameu_POSITIONAL_ONLYuNoneuformatu _annotationu_emptyuformatannotationu_defaulturepru_VAR_POSITIONALu _VAR_KEYWORD(uselfukindu formatted((u,/opt/alt/python33/lib64/python3.3/inspect.pyu__str__)s           uParameter.__str__cCs"dj|jjt||jS(Nu<{} at {:#x} {!r}>(uformatu __class__u__name__uiduname(uself((u,/opt/alt/python33/lib64/python3.3/inspect.pyu__repr__AsuParameter.__repr__cCsXt|jtoW|j|jkoW|j|jkoW|j|jkoW|j|jkS(N(u issubclassu __class__u Parameteru_nameu_kindu_defaultu _annotation(uselfuother((u,/opt/alt/python33/lib64/python3.3/inspect.pyu__eq__Es uParameter.__eq__cCs|j| S(N(u__eq__(uselfuother((u,/opt/alt/python33/lib64/python3.3/inspect.pyu__ne__LsuParameter.__ne__N(u_nameu_kindu_defaultu _annotationu_partial_kwargF(u__name__u __module__u __qualname__u__doc__u __slots__u_POSITIONAL_ONLYuPOSITIONAL_ONLYu_POSITIONAL_OR_KEYWORDuPOSITIONAL_OR_KEYWORDu_VAR_POSITIONALuVAR_POSITIONALu _KEYWORD_ONLYu KEYWORD_ONLYu _VAR_KEYWORDu VAR_KEYWORDu_emptyuemptyuFalseu__init__upropertyunameudefaultu annotationukindu_voidureplaceu__str__u__repr__u__eq__u__ne__(u __locals__((u,/opt/alt/python33/lib64/python3.3/inspect.pyu Parameters(   u ParametercBst|EeZdZdZddZeddZeddZedd Zd d Z d d Z dS(uBoundArgumentsuResult of `Signature.bind` call. Holds the mapping of arguments to the function's parameters. Has the following public attributes: * arguments : OrderedDict An ordered mutable mapping of parameters' names to arguments' values. Does not contain arguments' default values. * signature : Signature The Signature object that created this instance. * args : tuple Tuple of positional arguments values. * kwargs : dict Dict of keyword arguments values. cCs||_||_dS(N(u argumentsu _signature(uselfu signatureu arguments((u,/opt/alt/python33/lib64/python3.3/inspect.pyu__init__as uBoundArguments.__init__cCs|jS(N(u _signature(uself((u,/opt/alt/python33/lib64/python3.3/inspect.pyu signatureesuBoundArguments.signaturec Csg}x|jjjD]\}}|jttfksC|jrGPny|j|}Wntk rmPYqX|jt kr|j |q|j |qWt |S(N( u _signatureu parametersuitemsukindu _VAR_KEYWORDu _KEYWORD_ONLYu_partial_kwargu argumentsuKeyErroru_VAR_POSITIONALuextenduappendutuple(uselfuargsu param_nameuparamuarg((u,/opt/alt/python33/lib64/python3.3/inspect.pyuargsis  uBoundArguments.argsc Csi}d}x|jjjD]\}}|sv|jttfksO|jrXd}qv||j krvd}qqvn|sqny|j |}Wnt k rYqX|jtkr|j |q||| BoundArguments Creates a mapping from positional and keyword arguments to parameters. * bind_partial(*args, **kwargs) -> BoundArguments Creates a partial mapping from positional and keyword arguments to parameters (simulating 'functools.partial' behavior.) u_return_annotationu _parametersureturn_annotationu__validate_parameters__c Cs4|dkrt}n|rt}t}xt|D]\}}|j}||krd} | j||j} t| n|}|j} | dkrt|} |j d| }n| |krdj| } t| n||| su%Signature.__init__..N(uNoneu OrderedDictu_POSITIONAL_ONLYu enumerateukinduformatu ValueErrorunameustrureplaceutypesuMappingProxyTypeu _parametersu_return_annotation( uselfu parametersureturn_annotationu__validate_parameters__uparamsutop_kinduidxuparamukindumsguname((u,/opt/alt/python33/lib64/python3.3/inspect.pyu__init__s0           uSignature.__init__c Cst|tjs*tdj|n|j}|j}|j}|j}t |d|}|j }||||}|j } |j } |j } | rt| } nd} g} || }xI|d|D]7}| j|t}| j||d|dtqWx_t||dD]G\}}| j|t}| j||d|dtd| |q*W|jd@r|||}| j|t}| j||d|dtnxl|D]d}t}| dk r| j|t}n| j|t}| j||d|dtd|qW|jd@r||}|jd@rd|d 7}n||}| j|t}| j||d|dtn|| d | jd td d S(u2Constructs Signature for the given python functionu{!r} is not a Python functionNiu annotationukindudefaultiiiureturn_annotationureturnu__validate_parameters__F(u isinstanceutypesu FunctionTypeu TypeErroruformatu_parameter_clsu__code__u co_argcountu co_varnamesutupleuco_kwonlyargcountu__annotations__u __defaults__u__kwdefaults__ulenugetu_emptyuappendu_POSITIONAL_OR_KEYWORDu enumerateuco_flagsu_VAR_POSITIONALuNoneu _KEYWORD_ONLYu _VAR_KEYWORDuFalse(uclsufuncu Parameteru func_codeu pos_countu arg_namesu positionalukeyword_only_countu keyword_onlyu annotationsudefaultsu kwdefaultsupos_default_countu parametersunon_default_countunameu annotationuoffsetudefaultuindex((u,/opt/alt/python33/lib64/python3.3/inspect.pyu from_functionsd         #           uSignature.from_functioncCs|jS(N(u _parameters(uself((u,/opt/alt/python33/lib64/python3.3/inspect.pyu parameters:suSignature.parameterscCs|jS(N(u_return_annotation(uself((u,/opt/alt/python33/lib64/python3.3/inspect.pyureturn_annotation>suSignature.return_annotationu parameterscCsL|tkr|jj}n|tkr6|j}nt||d|S(uCreates a customized copy of the Signature. Pass 'parameters' and/or 'return_annotation' arguments to override them in the new copy. ureturn_annotation(u_voidu parametersuvaluesu_return_annotationutype(uselfu parametersureturn_annotation((u,/opt/alt/python33/lib64/python3.3/inspect.pyureplaceBs    uSignature.replacecCs2tt|t sF|j|jksFt|jt|jkrJdSddt|jjD}xt|jj D]\}\}}|j t kry|j|}Wnt k rdSYq*X||kr*dSqy||}Wnt k rdSYqX||ks&||j|krdSqWdS(NcSsi|]\}}||qS(((u.0uidxuparam((u,/opt/alt/python33/lib64/python3.3/inspect.pyu Ws u$Signature.__eq__..FT(u issubclassutypeu Signatureureturn_annotationulenu parametersuFalseu enumerateukeysuitemsukindu _KEYWORD_ONLYuKeyErroruTrue(uselfuotheruother_positionsuidxu param_nameuparamu other_paramu other_idx((u,/opt/alt/python33/lib64/python3.3/inspect.pyu__eq__Qs, (      uSignature.__eq__cCs|j| S(N(u__eq__(uselfuother((u,/opt/alt/python33/lib64/python3.3/inspect.pyu__ne__osuSignature.__ne__upartialcCst}t|jj}f}t|}|r~xE|jjD]1\}} | jrF||krF| j|| {}TF(uTrueu enumerateu parametersuvaluesustrukindu_VAR_POSITIONALuFalseu _KEYWORD_ONLYuappenduformatujoinureturn_annotationu_emptyuformatannotation( uselfuresulturender_kw_only_separatoruidxuparamu formattedukindurendereduanno((u,/opt/alt/python33/lib64/python3.3/inspect.pyu__str__s "      uSignature.__str__N(u_return_annotationu _parametersTF(u__name__u __module__u __qualname__u__doc__u __slots__u Parameteru_parameter_clsuBoundArgumentsu_bound_arguments_clsu_emptyuemptyuTrueuNoneu__init__u classmethodu from_functionupropertyu parametersureturn_annotationu_voidureplaceu__eq__u__ne__uFalseu_bindubindu bind_partialu__str__(u __locals__((u,/opt/alt/python33/lib64/python3.3/inspect.pyu Signatures" %I    u Signature(uKa-Ping Yee u'Yury Selivanov (ii(ii(ii i@iF(u__doc__u __author__uimpuimportlib.machineryu importlibu itertoolsu linecacheuosureusysutokenizeutypesuwarningsu functoolsubuiltinsuoperatoru attrgetteru collectionsu namedtupleu OrderedDictudisuCOMPILER_FLAG_NAMESu _flag_namesu ImportErroru CO_OPTIMIZEDu CO_NEWLOCALSu CO_VARARGSuCO_VARKEYWORDSu CO_NESTEDu CO_GENERATORu CO_NOFREEuglobalsumod_dictuitemsukuvuTPFLAGS_IS_ABSTRACTuismoduleuisclassuismethoduismethoddescriptoruisdatadescriptoruhasattruismemberdescriptoruisgetsetdescriptoru isfunctionuisgeneratorfunctionu isgeneratoru istracebackuisframeuiscodeu isbuiltinu isroutineu isabstractuNoneu getmembersu Attributeuclassify_class_attrsugetmrou indentsizeugetdocucleandocugetfileu ModuleInfou getmoduleinfou getmodulenameu getsourcefileu getabsfileu modulesbyfileu_filesbymodnameu getmoduleu findsourceu getcommentsu Exceptionu EndOfBlocku BlockFinderugetblockugetsourcelinesu getsourceuwalktreeuFalseu getclasstreeu Argumentsugetargsu _getfullargsuArgSpecu getargspecu FullArgSpecugetfullargspecuArgInfou getargvaluesuformatannotationuformatannotationrelativetoustru formatargspecuformatargvaluesu_missing_argumentsu _too_manyu getcallargsu ClosureVarsugetclosurevarsu Tracebacku getframeinfou getlinenougetouterframesugetinnerframesu currentframeustackutraceuobjectu _sentinelu_static_getmrou_check_instanceu _check_classu_is_typeu_shadowed_dictugetattr_staticu GEN_CREATEDu GEN_RUNNINGu GEN_SUSPENDEDu GEN_CLOSEDugetgeneratorstateugetgeneratorlocalsutypeu__call__u_WrapperDescriptoruallu_MethodWrapperuBuiltinFunctionTypeu_NonUserDefinedCallablesu_get_user_defined_methodu signatureu_voidu_emptyuintu_ParameterKindu_POSITIONAL_ONLYu_POSITIONAL_OR_KEYWORDu_VAR_POSITIONALu _KEYWORD_ONLYu _VAR_KEYWORDu ParameteruBoundArgumentsu Signature(((u,/opt/alt/python33/lib64/python3.3/inspect.pyus                           F       . C -'             )     > 5!       0    r ]