Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/inspect.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c	@s�dZdZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZd^\ZZZZd_\ZZZd`Zd�Zd�Zd�Zd�Zd�Zeed�r
d�Zn	d�Zeed�r1d�Zn	d�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d �Z&d!�Z'd"�Z(dd#�Z*ed$d%�Z+d&�Z,d'�Z-d(�Z.d)�Z/d*�Z0d+�Z1d,�Z2ed-d.�Z3d/�Z4d0�Z5d1�Z6dd2�Z7iZ8iZ9dd3�Z:d4�Z;d5�Z<d6e=fd7��YZ>d8dad9��YZ?d:�Z@d;�ZAd<�ZBd=�ZCd>d?�ZDed@dA�ZEdB�ZFedCdD�ZGdE�ZHedFdG�ZIdH�ZJdI�ZKeKdJ�ZLdddeMdK�dL�dM�eKdN�ZNeMdO�dP�dQ�eKdR�ZOdS�ZPedTdU�ZQddV�ZRdW�ZSddX�ZTddY�ZUeedZ�r�ejVZWndd[�ZWdd\�ZXdd]�ZYdS(bs�Get useful information from live Python objects.

This module encapsulates the interface provided by the internal special
attributes (func_*, 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
    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
sKa-Ping Yee <[email protected]>s
1 Jan 2001i�N(t
attrgetter(t
namedtupleiiiiii i@icCst|tj�S(s�Return true if the object is a module.

    Module objects provide these attributes:
        __doc__         documentation string
        __file__        filename (missing for built-in modules)(t
isinstancettypest
ModuleType(tobject((s/sys/lib/python2.7/inspect.pytismodule3scCst|ttjf�S(s�Return 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(RttypeRt	ClassType(R((s/sys/lib/python2.7/inspect.pytisclass;scCst|tj�S(s�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
        im_class        class object in which this method belongs
        im_func         function object containing implementation of method
        im_self         instance to which this method is bound, or None(RRt
MethodType(R((s/sys/lib/python2.7/inspect.pytismethodCs	cCsDt|d�oCt|d�oCt|�oCt|�oCt|�S(s�Return 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
    im_func attribute (etc) when an object passes ismethod().t__get__t__set__(thasattrRt
isfunctionR	(R((s/sys/lib/python2.7/inspect.pytismethoddescriptorNs


cCst|d�ot|d�S(s�Return 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.R
R(R(R((s/sys/lib/python2.7/inspect.pytisdatadescriptorbstMemberDescriptorTypecCst|tj�S(s�Return true if the object is a member descriptor.

        Member descriptors are specialized descriptors defined in extension
        modules.(RRR(R((s/sys/lib/python2.7/inspect.pytismemberdescriptornscCstS(s�Return true if the object is a member descriptor.

        Member descriptors are specialized descriptors defined in extension
        modules.(tFalse(R((s/sys/lib/python2.7/inspect.pyRvstGetSetDescriptorTypecCst|tj�S(s�Return true if the object is a getset descriptor.

        getset descriptors are specialized descriptors defined in extension
        modules.(RRR(R((s/sys/lib/python2.7/inspect.pytisgetsetdescriptorscCstS(s�Return true if the object is a getset descriptor.

        getset descriptors are specialized descriptors defined in extension
        modules.(R(R((s/sys/lib/python2.7/inspect.pyR�scCst|tj�S(sReturn 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
        func_code       code object containing compiled function bytecode
        func_defaults   tuple of any default values for arguments
        func_doc        (same as __doc__)
        func_globals    global namespace in which this function was defined
        func_name       (same as __name__)(RRtFunctionType(R((s/sys/lib/python2.7/inspect.pyR�scCs,tt|�st|�o(|jjt@�S(s�Return true if the object is a user-defined generator function.

    Generator function objects provides same attributes as functions.

    See help(isfunction) for attributes listing.(tboolRRt	func_codetco_flagstCO_GENERATOR(R((s/sys/lib/python2.7/inspect.pytisgeneratorfunction�scCst|tj�S(sReturn 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(RRt
GeneratorType(R((s/sys/lib/python2.7/inspect.pytisgenerator�scCst|tj�S(sbReturn 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)(RRt
TracebackType(R((s/sys/lib/python2.7/inspect.pytistraceback�scCst|tj�S(s|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_exc_traceback traceback if raised in this frame, or None
        f_exc_type      exception type if raised in this frame, or None
        f_exc_value     exception value if raised in this frame, or None
        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_restricted    0 or 1 if frame is in restricted execution mode
        f_trace         tracing function for this frame, or None(RRt	FrameType(R((s/sys/lib/python2.7/inspect.pytisframe�scCst|tj�S(suReturn 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(RRtCodeType(R((s/sys/lib/python2.7/inspect.pytiscode�scCst|tj�S(s,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(RRtBuiltinFunctionType(R((s/sys/lib/python2.7/inspect.pyt	isbuiltin�scCs.t|�p-t|�p-t|�p-t|�S(s<Return true if the object is any kind of function or method.(R&RRR(R((s/sys/lib/python2.7/inspect.pyt	isroutine�scCs tt|t�o|jt@�S(s:Return true if the object is an abstract base class (ABC).(RRRt	__flags__tTPFLAGS_IS_ABSTRACT(R((s/sys/lib/python2.7/inspect.pyt
isabstract�scCs~g}xgt|�D]Y}yt||�}Wntk
rBqnX|sV||�r|j||f�qqW|j�|S(s�Return all members of an object as (name, value) pairs sorted by name.
    Optionally, only return members that satisfy a given predicate.(tdirtgetattrtAttributeErrortappendtsort(Rt	predicatetresultstkeytvalue((s/sys/lib/python2.7/inspect.pyt
getmembers�s

t	Attributesname kind defining_class objectc
Csbt|�}t|�}g}x=|D]5}d}x\|f|D],}||jkr?|j|}|}Pq?q?Wt||�}t|d|�}t|t�r�d}n�t|t�r�d}n~t|t�r�d}nft	|�r�}nQt
|�rd}n<t||�}	t|	�s)t	|	�r2d}nd}|	}|jt
||||��q%W|S(s�Return 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.
    t__objclass__s
static methodsclass methodtpropertytmethodtdataN(tgetmroR+tNonet__dict__R,RtstaticmethodtclassmethodR7RRRR.R5(
tclstmrotnamestresulttnamethomeclstbasetobjtkindtobj_via_getattr((s/sys/lib/python2.7/inspect.pytclassify_class_attrss<

						 cCsB||krdS|j|�x|jD]}t||�q'WdS(N(R.t	__bases__t_searchbases(R?taccumRE((s/sys/lib/python2.7/inspect.pyRKLs

cCs7t|d�r|jSg}t||�t|�SdS(sHReturn tuple of base classes (including cls) in method resolution order.t__mro__N(RRMRKttuple(R?RB((s/sys/lib/python2.7/inspect.pyR:Ts

cCs,tj|�}t|�ttj|��S(sBReturn the indent size, in spaces, at the start of a line of text.(tstringt
expandtabstlentlstrip(tlinetexpline((s/sys/lib/python2.7/inspect.pyt
indentsize^scCsBy
|j}Wntk
r!dSXt|tj�s8dSt|�S(s�Get 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(t__doc__R-R;RRtStringTypestcleandoc(Rtdoc((s/sys/lib/python2.7/inspect.pytgetdoccs

cCsKytjtj|�d�}Wntk
r3dSXtj}xO|dD]C}ttj|��}|rHt|�|}t	||�}qHqHW|r�|dj�|d<n|tjkr�t
dt|��D]}|||||<q�Wnx|r|dr|j�q�"|r6|dr6|jd�qWtj|d�SdS(s�Clean up indentation from docstrings.

    Any whitespace that can be uniformly removed from the second line
    onwards is removed.s
iii�N(
ROtsplitRPtUnicodeErrorR;tsystmaxintRQRRtmintrangetpoptjoin(RYtlinestmarginRStcontenttindentti((s/sys/lib/python2.7/inspect.pyRXqs(
	cCst|�r:t|d�r"|jStdj|���nt|�r�tjj|j	�}t|d�rq|jStdj|���nt
|�r�|j}nt|�r�|j
}nt|�r�|j}nt|�r�j}nt|�r�jStdj|���dS(s@Work out which source or compiled file an object was defined in.t__file__s{!r} is a built-in modules{!r} is a built-in classsO{!r} is not a module, class, method, function, traceback, frame, or code objectN(RRRht	TypeErrortformatR	R]tmodulestgett
__module__Rtim_funcRRR ttb_frameR"tf_codeR$tco_filename(R((s/sys/lib/python2.7/inspect.pytgetfile�s*	t
ModuleInfosname suffix mode module_typecCs|tjj|�}td�tj��}|j�xA|D]9\}}}}|||kr;t|| |||�Sq;WdS(sDGet the module name, suffix, mode, and module type for a given file.cSs't|d�|d|d|dfS(Niii(RQ(tinfo((s/sys/lib/python2.7/inspect.pyt<lambda>�sN(tostpathtbasenametmaptimptget_suffixesR/Rs(Rwtfilenametsuffixestneglentsuffixtmodetmtype((s/sys/lib/python2.7/inspect.pyt
getmoduleinfo�s	
cCst|�}|r|dSdS(s1Return the module name for a given file, or None.iN(R�(RwRt((s/sys/lib/python2.7/inspect.pyt
getmodulename�scCs�t|�}tj|d�dkr6|d d}nxMtj�D]?\}}}d|krCtj|t|��|krCdSqCWtjj	|�r�|St
t||�d�r�|S|tj
kr�|SdS(	s�Return the filename that can be used to locate an object's source.
    Return None if no way can be identified to get the source.
    i�s.pycs.pyos.pytbt
__loader__N(s.pycs.pyo(RrROtlowerRzR{RQR;RvRwtexistsRt	getmodulet	linecachetcache(RR|RR�RG((s/sys/lib/python2.7/inspect.pyt
getsourcefile�s,cCsC|dkr't|�p!t|�}ntjjtjj|��S(s�Return 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(R;R�RrRvRwtnormcasetabspath(Rt	_filename((s/sys/lib/python2.7/inspect.pyt
getabsfile�sc
Cst|�r|St|d�r2tjj|j�S|dk	r^|tkr^tjjt|�Syt||�}Wnt	k
r�dSX|tkr�tjjt|�Sx�tjj
�D]�\}}t|�r�t|d�r�|j}|tj|d�krq�n|t|<t|�}|j
t|<ttjj|�<q�q�W|tkrbtjjt|�Stjd}t|d�s�dSt||j
�r�t||j
�}||kr�|Sntjd}t||j
�r�||j
�}	|	|kr�SndS(sAReturn the module an object was defined in, or None if not found.RmRht__main__t__name__t__builtin__N(RRR]RkRlRmR;t
modulesbyfileR�RititemsRht_filesbymodnameR�RvRwtrealpathR,(
RR�tfiletmodnametmoduletftmaint
mainobjecttbuiltint
builtinobject((s/sys/lib/python2.7/inspect.pyR��sD
	
(

cCs�t|�}t|�}|rF|d |ddkrFtd��n|rR|n|}t||�}|r�tj||j�}ntj|�}|s�td��nt|�r�|dfSt|�r�|j	}t
jd|d�}g}xptt
|��D]\}|j||�}	|	r||dd	krA||fS|j|	jd�|f�qqW|r�|j�||ddfStd
��nt|�r�|j}nt|�r�|j}nt|�r�|j}nt|�r�j}nt|�ryt|d�std��n|jd}
t
jd
�}x1|
dkrn|j||
�raPn|
d}
q>W||
fStd��dS(sbReturn the entire source file and starting line number for an object.

    The argument may be a module, class, method, function, traceback, frame,
    or code object.  The source code is returned as a list of all the lines
    in the file and the line number indexes a line in that list.  An IOError
    is raised if the source code cannot be retrieved.ii�s<>ssource code not availablescould not get source codeis^(\s*)class\s*s\btcscould not find class definitiontco_firstlinenos"could not find function definitions+^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)scould not find code objectN(RrR�tIOErrorR�R�tgetlinesR<RR	R�tretcompileR`RQtmatchR.tgroupR/RRnRRR RoR"RpR$RR�(RR�t
sourcefileR�RcRCtpatt
candidatesRgR�tlnum((s/sys/lib/python2.7/inspect.pyt
findsources\
	
#


cCs�yt|�\}}Wnttfk
r0dSXt|�r8d}|rf|dd dkrfd}nx9|t|�kr�tj||�d	kr�|d}qiW|t|�kr�||d dkr�g}|}xN|t|�kr$||d dkr$|jtj	||��|d}q�Wtj
|d�Sn�|dkr�t||�}|d}|dkr�tj||�d dkr�t||�|kr�tjtj	||��g}|dkra|d}tjtj	||��}xp|d dkr]t||�|kr]|g|d*|d}|dkr>Pntjtj	||��}q�x-|r�tj|d�dkr�g|d*qdWx-|r�tj|d�dkr�g|d)q�Wtj
|d�SndS(
swGet lines of comments immediately preceding an object's source code.

    Returns None when source can't be found.
    iis#!itt#i�N(R�R�(
R�R�RiR;RRQROtstripR.RPRbRURR(RRcR�tstarttcommentstendRftcomment((s/sys/lib/python2.7/inspect.pytgetcommentsIsJ	.&)
)
)

#""t
EndOfBlockcBseZRS((R�Rm(((s/sys/lib/python2.7/inspect.pyR�vstBlockFindercBs eZdZd�Zd�ZRS(s@Provide a tokeneater() method to detect the end of a code block.cCs1d|_t|_t|_t|_d|_dS(Nii(RfRtislambdatstartedtpasslinetlast(tself((s/sys/lib/python2.7/inspect.pyt__init__zs
				c
Cs8|\}}|\}}	|js]|dkrQ|dkrEt|_nt|_nt|_n�|tjkr�t|_||_|jr4t�q4n�|jr�n�|tj	kr�|j
d|_
t|_nj|tjkr|j
d|_
|j
dkr4t�q4n0|j
dkr4|tjtj
fkr4t�ndS(Ntdeftclasstlambdaii(R�R�slambda(R�tTrueR�R�ttokenizetNEWLINERR�R�tINDENTRftDEDENTtCOMMENTtNL(
R�Rttokent	srow_scolt	erow_ecolRStsrowtscolterowtecol((s/sys/lib/python2.7/inspect.pyt
tokeneater�s0					'(R�RmRVR�R�(((s/sys/lib/python2.7/inspect.pyR�xs	cCsNt�}y tjt|�j|j�Wnttfk
rBnX||j S(s@Extract the block of code at the top of the given list of lines.(R�R�titertnextR�R�tIndentationErrorR�(Rctblockfinder((s/sys/lib/python2.7/inspect.pytgetblock�s	 cCsDt|�\}}t|�r(|dfSt||�|dfSdS(s�Return a list of source lines and starting line number for an object.

    The argument may be a module, class, method, function, traceback, frame,
    or code object.  The source code is returned as a list of the lines
    corresponding to the object and the line number indicates where in the
    original source file the first line of code was found.  An IOError is
    raised if the source code cannot be retrieved.iiN(R�RR�(RRcR�((s/sys/lib/python2.7/inspect.pytgetsourcelines�s
cCs"t|�\}}tj|d�S(sReturn the text of the source code for an object.

    The argument may be a module, class, method, function, traceback, frame,
    or code object.  The source code is returned as a single string.  An
    IOError is raised if the source code cannot be retrieved.R�(R�RORb(RRcR�((s/sys/lib/python2.7/inspect.pyt	getsource�scCsvg}|jdtdd��xP|D]H}|j||jf�||kr&|jt||||��q&q&W|S(s-Recursive helper function for getclasstree().R2RmR�(R/RR.RJtwalktree(tclassestchildrentparentR1R�((s/sys/lib/python2.7/inspect.pyR��s
$icCs�i}g}x�|D]�}|jr�x�|jD]Y}||krKg||<n|||kro||j|�n|r,||kr,Pq,q,Wq||kr|j|�qqWx*|D]"}||kr�|j|�q�q�Wt||d�S(s�Arrange the given list of classes into a hierarchy of nested lists.

    Where a nested list appears, it contains classes derived from the class
    whose entry immediately precedes the list.  Each entry is a 2-tuple
    containing a class and a tuple of its base classes.  If the 'unique'
    argument is true, exactly one entry appears in the returned structure
    for each class in the given list.  Otherwise, classes using multiple
    inheritance and their descendants will appear multiple times.N(RJR.R�R;(R�tuniqueR�trootsR�R�((s/sys/lib/python2.7/inspect.pytgetclasstree�s"	
	

t	Argumentssargs varargs keywordscCsft|�s$tdj|���n|j}|j}t|| �}d}x�t|�D]�}||d dkrYggg}}}xg|t|j�kr�|j|�}	|d}|	t
jkr�t
j|	}
t	|j|�t	|j|d�d}|d}|
d
kr7|j
|�|j
|�q�
d
kr�j
||�|so|dg|d<Pq�dd|d<xY|ddkr�|j�|j�}||g||)|s�Pn|dd|d<q�W|s�q���q�W|d||<qYqYWd}
|jt@r3|j|}
|d}nd}|jt@rV|j|}nt||
|�S(sGet information about the arguments accepted by a code object.

    Three things are returned: (args, varargs, varkw), where 'args' is
    a list of argument names (possibly containing nested lists), and
    'varargs' and 'varkw' are the names of the * and ** arguments or None.s{!r} is not a code objectiiR�t.iitUNPACK_TUPLEtUNPACK_SEQUENCEt
STORE_FASTi�(R�R�(R�R�N(R$RiRjtco_argcounttco_varnamestlistR`RQtco_codetordtdist
HAVE_ARGUMENTtopnameR.RaR;Rt
CO_VARARGStCO_VARKEYWORDSR�(tcotnargsRAtargststepRgtstacktremaintcounttopR�R3tsizetvarargstvarkw((s/sys/lib/python2.7/inspect.pytgetargs�sV		

,






tArgSpecsargs varargs keywords defaultscCsjt|�r|j}nt|�s<tdj|���nt|j�\}}}t||||j�S(slGet the names and default values of a function's arguments.

    A tuple of four things is returned: (args, varargs, varkw, defaults).
    'args' is a list of the argument names (it may contain nested lists).
    'varargs' and 'varkw' are the names of the * and ** arguments or None.
    'defaults' is an n-tuple of the default values of the last n arguments.
    s{!r} is not a Python function(	RRnRRiRjR�RR�t
func_defaults(tfuncR�R�R�((s/sys/lib/python2.7/inspect.pyt
getargspec$s	tArgInfosargs varargs keywords localscCs.t|j�\}}}t||||j�S(sWGet information about arguments passed into a particular frame.

    A tuple of four things is returned: (args, varargs, varkw, locals).
    'args' is a list of the argument names (it may contain nested lists).
    'varargs' and 'varkw' are the names of the * and ** arguments or None.
    'locals' is the locals dictionary of the given frame.(R�RpR�tf_locals(tframeR�R�R�((s/sys/lib/python2.7/inspect.pytgetargvalues6scCs>t|�dkr"d|ddSdtj|d�dSdS(Nit(is,)s, t)(RQRORb(tseq((s/sys/lib/python2.7/inspect.pytjoinseq@scCsBt|�ttfkr4|t||d�|��S||�SdS(s7Recursively walk a sequence, stringifying each element.cSst|||�S(N(tstrseq(toR�tj((s/sys/lib/python2.7/inspect.pyRuIsN(RR�RNRy(RtconvertRb((s/sys/lib/python2.7/inspect.pyRFscCsd|S(Nt*((RC((s/sys/lib/python2.7/inspect.pyRuOscCsd|S(Ns**((RC((s/sys/lib/python2.7/inspect.pyRuPscCsdt|�S(Nt=(trepr(R3((s/sys/lib/python2.7/inspect.pyRuQsc	Cs�g}	|r%t|�t|�}
nxft|�D]X\}}t|||�}
|r}||
kr}|
||||
�}
n|	j|
�q2W|dk	r�|	j||��n|dk	r�|	j||��ndtj|	d�dS(sgFormat an argument spec from the 4 values returned by getargspec.

    The first four arguments are (args, varargs, varkw, defaults).  The
    other 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.R�s, RN(RQt	enumerateRR.R;RORb(R�R�R�tdefaultst	formatargt
formatvarargstformatvarkwtformatvalueRbtspecstfirstdefaultRgtargtspec((s/sys/lib/python2.7/inspect.pyt
formatargspecMscCsd|S(NR((RC((s/sys/lib/python2.7/inspect.pyRuiscCsd|S(Ns**((RC((s/sys/lib/python2.7/inspect.pyRujscCsdt|�S(NR(R	(R3((s/sys/lib/python2.7/inspect.pyRuksc	Cs�|||d�}	g}
x7tt|��D]#}|
jt|||	|��q+W|r||
j||�|||��n|r�|
j||�|||��ndtj|
d�dS(sfFormat 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((RCtlocalsRR((s/sys/lib/python2.7/inspect.pyRssR�s, R(R`RQR.RRORb(R�R�R�RRR
RRRbRRRg((s/sys/lib/python2.7/inspect.pytformatargvaluesgs!$$cs�t|�\}}}}|j}i�g����fd����fd�}t|�r�|jdk	r�|jf|}nt|�}	|	t|�}
t|�}|r�t|�nd}x*t||�D]\}
}�|
|�q�W|r*|	|kr�|||	|�q��|d�n�d|koA|	knr�td||r[dnd||dkrsdnd	|
f��nS|dkr�|
r�|r�|	r�td
||
f��q�q�td||
f��nxg|D]_}
t|
t	�r�
|kr�|
�r&td||
f��q?�|
|j
|
��q��|r�xAt|||�D](\}
}||
�s^�|
|�q^q^Wn|r��||�n[|r�t|��}t|t
�r�jtj�d
�}ntd||f��n|tg|D]}
||
�r|
^q�}|r}||}td||rRdnd||dkrjdnd	|
f��n�S(s�Get the mapping of arguments to values.

    A dict is returned, with keys the function argument names (including the
    names of the * and ** arguments, if any), and values the respective bound
    values from 'positional' and 'named'.cs�t|t�r|�|<n��j|�t|�}xst|�D]e\}}yt|�}Wn9tk
r�td||dkr�dndf��nX�||�qBWyt|�Wntk
r�n
Xtd��dS(Nsneed more than %d %s to unpackitvaluesR3stoo many values to unpack(RtstrR.R�R
R�t
StopIterationt
ValueError(RR3Rgtsubargtsubvalue(t	arg2valuetassigntassigned_tuple_params(s/sys/lib/python2.7/inspect.pyR�s 


&
cs#t|t�r|�kS|�kS(N(RR(R(RR(s/sys/lib/python2.7/inspect.pytis_assigned�s
is%s() takes %s %d %s (%d given)sat mosttexactlyit	argumentstarguments)%s() takes exactly 0 arguments (%d given)s"%s() takes no arguments (%d given)s2%s() got multiple values for keyword argument '%s'treplaces,%s() got an unexpected keyword argument '%s'sat leastN((R�R�Rtim_selfR;RQtzipRiRRRaR�R�tunicodetencodeR]tgetdefaultencoding(R�t
positionaltnamedR�R�R�Rtf_nameR tnum_post	num_totaltnum_argstnum_defaultsRR3t
unexpectedt
unassignedtnum_required((RRRs/sys/lib/python2.7/inspect.pytgetcallargssl	%
!/
%t	Tracebacks+filename lineno function code_context indexcCs1t|�r!|j}|j}n	|j}t|�sNtdj|���nt|�pct|�}|dkr|d|d}yt	|�\}}Wnt
k
r�d}}qXt|d�}tdt
|t|�|��}||||!}|d|}n
d}}t|||jj||�S(s�Get 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.s'{!r} is not a frame or traceback objectiiiN(R t	tb_linenoRotf_linenoR"RiRjR�RrR�R�R;tmaxR_RQR5Rptco_name(R�tcontexttlinenoR|R�RcR�tindex((s/sys/lib/python2.7/inspect.pytgetframeinfo�s&		
"
cCs|jS(sCGet the line number from a frame object, allowing for optimization.(R7(R�((s/sys/lib/python2.7/inspect.pyt	getlineno�scCs=g}x0|r8|j|ft||��|j}q	W|S(s�Get 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.(R.R=tf_back(R�R:t	framelist((s/sys/lib/python2.7/inspect.pytgetouterframess
	
cCs@g}x3|r;|j|jft||��|j}q	W|S(s�Get 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.(R.RoR=ttb_next(ttbR:R@((s/sys/lib/python2.7/inspect.pytgetinnerframes
s
	 
t	_getframecCsdS(N(R;(t_((s/sys/lib/python2.7/inspect.pyRuscCsttjd�|�S(s@Return a list of records for the stack above the caller's frame.i(RAR]RE(R:((s/sys/lib/python2.7/inspect.pyR�scCsttj�d|�S(sCReturn a list of records for the stack below the current exception.i(RDR]texc_info(R:((s/sys/lib/python2.7/inspect.pyttrace!s(iiii(ii i@i((ZRVt
__author__t__date__R]RvRROR�R�RzR�R�toperatorRtcollectionsRtCO_OPTIMIZEDtCO_NEWLOCALSR�R�t	CO_NESTEDRt	CO_NOFREER)RR	RRRRRRRRRR R"R$R&R'R*R;R4R5RIRKR:RURZRXRrRsR�R�R�R�R�R�R�R�R�t	ExceptionR�R�R�R�R�R�R�R�R�R�R�R�R�RRRRRR4R5R=R>RARDREtcurrentframeR�RH(((s/sys/lib/python2.7/inspect.pyt<module>s�					
			
				
							E		
								.	C	-)			
	
	
	:		
			[!	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].