Your IP : 216.73.216.196


Current Path : /opt/alt/python27/lib/python2.7/site-packages/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/decorator.pyc

�
�D�Vc@s�dZddlmZddlZddlZddlZddlZddlZddlZdZ	ej
dkr�ddlmZd�Znde
fd	��YZd
�Zejdd�Zd
�Zejd�Zde
fd��YZd�Zdd�ZyddlmZWn!ek
r:ddlmZnXdefd��YZeej�Zeej�Z e dkr�ej!r�d�Zee_n9e dkr�ej!r�n!e dkr�d�Zee_nee�Z"d�Z#d�Z$dS(sT
Decorator module, see http://pypi.python.org/pypi/decorator
for the documentation.
i����(tprint_functionNs4.0.10t3(tgetfullargspeccCs|jS(N(t__init__(tcls((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pytget_init0sRcBs)eZdZd�Zd�ZejZRS(s?A quick and dirty replacement for getfullargspec for Python 2.XcCs=tj|�\|_|_|_|_g|_d|_dS(N(	tinspectt
getargspectargstvarargstvarkwtdefaultst
kwonlyargstNonetkwonlydefaults(tselftf((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyR5s'	ccs$|jV|jV|jV|jVdS(N(RR	R
R(R((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyt__iter__;s(t__name__t
__module__t__doc__RRRR(((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyR3s		cCs
|jjS(N(Rt__func__(R((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyRCstArgSpecsargs varargs varkw defaultscCs+t|�}t|j|j|j|j�S(s$A replacement for inspect.getargspec(RRRR	R
R(Rtspec((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyRKss\s*def\s*([_\w][_\w\d]*)\s*\(t
FunctionMakercBskeZdZej�Zdddddddd�Zd�Zde	d�Z
eddded��Z
RS(s�
    An object with the ability to create functions with a given signature.
    It has attributes name, doc, module, signature, defaults, dict and
    methods update and make.
    cCs�||_|r.|j|_|jdkr6d|_n|j|_|j|_tj|�r.t	|�}t
|di�|_x'dD]}	t||	t
||	��q�Wx1t
|j�D] \}
}t|d
|
|�q�Wtjdkrtjdd
�|�dd!|_|_n�t|j�}t|j�}
|jri|jd|j�|
jd|j�n|jr�|jd�nx9|jD].}	|jd|	�|
jd|	|	f�q�W|jr�|jd|j�|
jd|j�ndj|�|_dj|
�|_|jj�|_q.n|r@||_n|dk	rX||_n|rj||_n|r|||_n|r�||_n|r�||_nt|d�s�t�t|d�s�t d|��ndS(Ns<lambda>t_lambda_t__annotations__RR	R
RRRsarg%dRtformatvaluecSsdS(Nt((tval((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyt<lambda>sRii����t*s%s=Nones%s=%ss**s, tnamet	signatures%You are decorating a non function: %s(RR	R
RRR(!tshortsignatureRR RtdocRtmoduleRt
isfunctionRtgetattrtannotationstsetattrt	enumerateRtsystversiont
formatargspecR!tlistR	tappendRR
tjoint__dict__tcopytdictR
RthasattrtAssertionErrort	TypeError(RtfuncR R!RR#R$tfuncdicttargspectatitargtallargstallshortargs((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyR^sb	
	#			cKs�|j|_t|dd
�|_t|di�|_t|dd�|_t|dd
�|_t|dd
�|_yt	j
d�}Wntk
r�d}nX|jj
dd�}t|d	|�|_|jj|�d
S(s2Update the signature of func with the data in selfR#R2RRR'it?RR$N((R RR&R
RR0t__defaults__t__kwdefaults__RR*t	_getframetAttributeErrort	f_globalstgetRtupdate(RR6tkwtframetcallermodule((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyRE�s

cJs~|e|�}|pi}ej|�}|dkrJed|��n|jd�}e|gg|jjd�D]}|j	d�^qu�}	x3|	D]+}
|
dkr�e
d|
|f��q�q�W|jd�s�|d7}nd	e|j
�f}ye||d
�}||UWn0eddej�e|dej��nX||}
|rj||d
<n|j|
|�|
S(sBMake a new function from a given template and update the signatures not a valid function template
%sit,s *t_func_t_call_s%s is overridden in
%ss
s<decorator-gen-%d>tsinglesError in generated code:tfilet
__source__N(RJRK(tvarstDEFtmatchR
tSyntaxErrortgrouptsetR"tsplittstript	NameErrortendswithtnextt_compile_counttcompiletprintR*tstderrRE(Rt	src_templtevaldictt	addsourcetattrstsrctmoR R;tnamestntfilenametcodeR6((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pytmake�s4/



cKs�t|t�r@|j�jdd�\}	}
|
d }d}nd}	d}|}|||	||||�}
djd�|j�D��}|
jd||||�S(s�
        Create a function from the strings name, signature and body.
        evaldict is the evaluation dictionary. If addsource is true an
        attribute __source__ is added to the result. The attributes attrs
        are added, if any.
        t(ii����s
css|]}d|VqdS(s    N((t.0tline((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pys	<genexpr>�ssdef %(name)s(%(signature)s):
N(t
isinstancetstrRVRUR
R/t
splitlinesRh(RtobjtbodyR_RR#R$R`RaR trestR!R6Rtibody((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pytcreate�s	
	
N(RRRt	itertoolstcountRZR
RREtFalseRhtclassmethodtTrueRs(((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyRTs	8	"cCsRtd|d|�}tj|d|d|�}t|d�rN|j|_n|S(sE
    decorate(func, caller) decorates a function using a caller.
    RKRJs)return _call_(_func_, %(shortsignature)s)t__wrapped__t__qualname__(R2RRsR3Rz(R6tcallerR_tfun((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pytdecorate�sc
Cs�|dk	rt||�Stj|�rP|jj�}d|j|jf}nZtj|�r�|jdkrwd}n	|j}|j}n|jjj�}|j	j}t
d|dt�}tjd|d|d|d	|j
d
|�S(s=decorator(caller) converts a caller function into a decoratorsHdecorator(%s) converts functions/generators into factories of %s objectss<lambda>RRKt
_decorate_s%s(func)sreturn _decorate_(func, _call_)R#R$RyN(R
R}RtisclassRtlowerR%Rt	__class__t__call__R2RRsR(R{t_funcR R#R_((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyt	decorator�s$
		
(t_GeneratorContextManager(tGeneratorContextManagertContextManagercBseZd�ZRS(cCs(tj|dtd|d|�d|�S(sContext manager decorators.with _self_: return _func_(%(shortsignature)s)t_self_RJRy(RRsR2(RR6((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyR�s(RRR�(((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyR�sicOstj||||��S(N(R�R(RtgR9tk((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyRsicOstj||||�S(N(R�R(RR�R9R�((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyR scCsxt}xUt|�D]G\}}t||�r8t}Pnt||�r|||<t}qqW|rt|j|�ndS(s_
    Append ``a`` to the list of the virtual ancestors, unless it is already
    included.
    N(RxR)t
issubclassRvR.(R9t
vancestorstaddtjtva((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyR.)s

csc�std��ddj���tjd�fd�����fd�}d�|_|S(sr
    Factory of decorators turning a function into a generic function
    dispatching on the given arguments.
    sNo dispatch args passeds(%s,)s, RcsG|t|�t���rCtdt��t|�|f��ndS(s5Make sure one passes the expected number of argumentssExpected %d arguments, got %d%sN(tlenR5(t	argumentstwrongtmsg(t
dispatch_args(s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pytcheckCscs�tt��j�}t��|ks:td���ni����fd����fd����fd�}��fd�}���fd�}tj�d�td|�d	|d
�d�d�d
�d|d��S(s4Decorator turning a function into a generic functionsUnknown dispatch arguments %scs��|�gtt���D]}g^q}xb�D]Z}xQt|||�D]=\}}}t||�rO||jkrOt||�qOqOWq6Wg|D]}t|�^q�S(sU
            Get a list of sets of virtual ancestors for the given types
            (trangeR�tzipR�t__mro__R.RT(ttypest_trasttypes_ttttype_tra(R�R�ttypemap(s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyR�Ss
%
"cs��|�g}x�t|�|��D]�\}}t|�}|dkrctd||f��n@|dkr�|\}td||fi�jd}n	|j}|j|d �q&W|S(sG
            Get a list of virtual MROs, one for each type
            isAmbiguous dispatch for %s: %sR�i����(R�R�tRuntimeErrorttypeR�R.(R�tlistsR�tvastn_vasR�tmro(R�R�(s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyt	ancestors_s
"	"	cs#������fd�}|S(sU
            Decorator to register an implementation for the given types
            cs1�t|�jtjd|j�|��<|S(Ns in (RRtoperatortltR(R(R�R�R�(s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pytdecxs#
((R�R�(R�R�(R�s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pytregisterrs
csQ�|�g}x:tj�|��D]#}|jtd�|D���q&W|S(sI
            An utility to introspect the dispatch algorithm
            css|]}|jVqdS(N(R(RjR9((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pys	<genexpr>�s(RttproductR.ttuple(R�tlsttanc(R�R�(s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyt
dispatch_info~s

!cs�td�|D��}y�|}Wntk
r7nX|||�Stj�|��}t|�x6|D].}�j|�}|dk	rk|||�SqkW�||�S(Ncss|]}t|�VqdS(N(R�(RjR;((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pys	<genexpr>�s(R�tKeyErrorRtR�RYRDR
(R�RRFR�RtcombinationsR�(R�R6R�(s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyt	_dispatch�s



s#return _f_(%s, %%(shortsignature)s)t_f_R�tdefaultR�R�R�R�Ry(RTRRRWRRsR2(R6targsetR�R�R�(R�R�tdispatch_str(R�R6R�R�s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pytgen_func_decIs

tdispatch_on(R4R/R�tneR(R�R�((R�R�R�s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyR�;sW
(%Rt
__future__RtreR*RR�Rttcollectionst__version__R+RRtobjectt
namedtupleRRR[RPRR}R
R�t
contextlibR�tImportErrorR�R�RtinitR�Rtn_argsR	tcontextmanagerR.R�(((s:/opt/alt/python27/lib/python2.7/site-packages/decorator.pyt<module>!sL		�