Your IP : 3.145.99.221


Current Path : /opt/alt/python37/lib/python3.7/site-packages/jinja2/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/jinja2/__pycache__/idtracking.cpython-37.opt-1.pyc

B

^�a�)�@s�ddlZddlmZddlmZdZdZdZdZ	dej
ejejd	d	d
�dd�Z
dejejd	d	d
�dd�ZGdd	�d	�ZGdd�de�ZGdd�de�ZdS)�N�)�nodes)�NodeVisitor�paramZresolve�aliasZ	undefined�Symbols)r�parent_symbols�returncCs.t|d�}t|�}x|D]}|�|�qW|S)N)�parent)r�FrameSymbolVisitor�visit)rr�sym�visitor�node�r�B/opt/alt/python37/lib/python3.7/site-packages/jinja2/idtracking.py�find_symbolss


r)rrr	cCst|d�}|�|�|S)N)r
)r�analyze_node)rrr
rrr�symbols_for_nodes

rc@s*eZdZd#ejdejedd�dd�Zejej	dd�dd�Z
d$eejejeejefed�d	d
�Z
eejej	d�dd
�Zeejed�dd�Zeed�dd�Zdd�dd�Zedd�dd�Zeed�dd�Zedd�dd�Zejddd�dd�Zejeefd�dd �Zejed�d!d"�ZdS)%rN)r
�levelr	cCsD|dkr |dkrd}n
|jd}||_||_i|_i|_t�|_dS)Nrr)rr
�refs�loads�set�stores)�selfr
rrrr�__init__s
zSymbols.__init__)r�kwargsr	cKst|�}|j|f|�dS)N)�RootVisitorr)rrrrrrrr.szSymbols.analyze_node)�name�loadr	cCs2d|j�d|��}||j|<|dk	r.||j|<|S)NZl_�_)rrr)rrr�identrrr�_define_ref2s


zSymbols._define_ref)�targetr	cCs.||jkr|j|S|jdk	r*|j�|�SdS)N)rr
�	find_load)rr#rrrr$;s



zSymbols.find_load)rr	cCs.||jkr|j|S|jdk	r*|j�|�SdS)N)rr
�find_ref)rrrrrr%Ds



zSymbols.find_refcCs&|�|�}|dkr"td|�d���|S)NzFTried to resolve a name to a reference that was unknown to the frame (�))r%�AssertionError)rr�rvrrr�refMs

zSymbols.ref)r	cCsJt�tt�|j��}|j�|j�|j�	�|_|j
�	�|_
|j�	�|_|S)N)�t�castr�object�__new__�	__class__�__dict__�updater�copyrr)rr(rrrr1VszSymbols.copycCs`|j�|�||jkr\|jdk	rJ|j�|�}|dk	rJ|j|t|fd�dS|j|tdfd�dS)N)r)r�addrr
r%r"�VAR_LOAD_ALIAS�VAR_LOAD_UNDEFINED)rrZ	outer_refrrr�store^s

z
Symbols.storecCs|j�|�|j|tdfd�S)N)r)rr2r"�VAR_LOAD_PARAMETER)rrrrr�declare_parameterpszSymbols.declare_parametercCs$|�|�dkr |j|t|fd�dS)N)r)r%r"�VAR_LOAD_RESOLVE)rrrrrrtszSymbols.load)�branch_symbolsr	c	Cs�i}x<|D]4}x.|jD]$}||jkr&q|�|d�d||<qWq
Wx6|D].}|j�|j�|j�|j�|j�|j�qHWxx|��D]l\}}|t|�kr�q�|�|�}|dk	s�td��|j	dk	r�|j	�|�}|dk	r�t
|f|j|<q�t|f|j|<q�WdS)Nrrzshould not happen)r�getrr0r�items�lenr%r'r
r3r8)	rr9r�branchr#r
rZbranch_countZouter_targetrrr�
branch_updatexs*




zSymbols.branch_updatecCsJi}|}x<|dk	rDx(t|j�D]}||kr|�|�||<qW|j}q
W|S)N)�sortedrr%r
)rr(rrrrr�dump_stores�s

zSymbols.dump_storescCsPt�}|}x@|dk	rJx,|j��D]\}\}}|tkr |�|�q W|j}qW|S)N)rrr;r6r2r
)rr(rr#Zinstrr rrr�dump_param_targets�s

zSymbols.dump_param_targets)NN)N)�__name__�
__module__�__qualname__r*�Optional�intrr�Node�Anyr�strZTupler"r$r%r)r1r5r7r�Sequencer>ZDictr@�SetrArrrrrs
			
c@s�eZdZddd�dd�Zejejdd�dd�ZeZ	eZ
eZeZeZ
eZeZejejdd�d	d
�Zejejdd�dd�Zejejdd�d
d�Zdejeejdd�dd�Zejejdd�dd�Zejejejdd�dd�ZdS)rrN)�symbolsr	cCst|�|_dS)N)r�sym_visitor)rrLrrrr�szRootVisitor.__init__)rrr	cKs"x|��D]}|j�|�q
WdS)N)�iter_child_nodesrMr)rrr�childrrr�
_simple_visit�szRootVisitor._simple_visitcKs x|jD]}|j�|�qWdS)N)�bodyrMr)rrrrOrrr�visit_AssignBlock�szRootVisitor.visit_AssignBlockcKs&x |jdd�D]}|j�|�qWdS)N)�call)Zexclude)rNrMr)rrrrOrrr�visit_CallBlock�szRootVisitor.visit_CallBlockcKs x|jD]}|j�|�qWdS)N)rQrMr)rrrrOrrr�visit_OverlayScope�szRootVisitor.visit_OverlayScoperQ)r�
for_branchrr	cKs�|dkr"|jj|jdd�|j}nN|dkr2|j}n>|dkrh|jj|jdd�|jdk	rd|j�|j�dStd��|r�x|D]}|j�|�qzWdS)NrQT)�store_as_param�else�testzUnknown for branch)rMrr#rQ�else_rY�RuntimeError)rrrVrr=�itemrrr�	visit_For�s

zRootVisitor.visit_ForcKs<x|jD]}|j�|�qWx|jD]}|j�|�q$WdS)N)�targetsrMrrQ)rrrr#rOrrr�
visit_With�szRootVisitor.visit_With)r�argsrr	cOstdt|�j����dS)NzCannot find symbols for )�NotImplementedError�typerB)rrr`rrrr�
generic_visit�szRootVisitor.generic_visit)rQ)rBrCrDrrrGr*rHrPZvisit_Template�visit_Block�visit_Macro�visit_FilterBlock�visit_Scope�visit_IfZvisit_ScopedEvalContextModifier�AssignBlockrR�	CallBlockrT�OverlayScoperU�ForrIr]�Withr_rcrrrrr�s rc@sneZdZdZddd�dd�Zd(ejeej	dd�d	d
�Z
ejej	dd�dd
�Zej
ej	dd�dd�Zejej	dd�dd�Zejej	dd�dd�Zejej	dd�dd�Zejej	dd�dd�Zejej	dd�dd�Zejej	dd�dd�Zejej	dd�dd�Zejej	dd�dd�Zejej	dd�d d!�Z ej!ej	dd�d"d#�Z"ej#ej	dd�d$d%�Z$ej%ej	dd�d&d'�Z&dS))rzA visitor for `Frame.inspect`.rN)rLr	cCs
||_dS)N)rL)rrLrrrr�szFrameSymbolVisitor.__init__F)rrWrr	cKsT|s|jdkr|j�|j�n2|jdkr8|j�|j�n|jdkrP|j�|j�dS)z2All assignments to names go through this function.rr5rN)ZctxrLr7rr5r)rrrWrrrr�
visit_Name�s

zFrameSymbolVisitor.visit_Name)rrr	cKs|j�|j�dS)N)rLrr)rrrrrr�visit_NSRef�szFrameSymbolVisitor.visit_NSRefcsn�j|jf���j�tjtjdd����fdd�}||j�}||j�}||j	pTd�}�j�
|||g�dS)Nr)rr	cs4����_}x|D]}�j|f��qW��_|S)N)r1rLr)rr(Zsubnode)r�original_symbolsrrr�inner_visits

z0FrameSymbolVisitor.visit_If.<locals>.inner_visitr)rrYrLr*�IterablerrGrQZelif_rZr>)rrrrqZbody_symbolsZelif_symbolsZelse_symbolsr)rrprrrh�s 	

zFrameSymbolVisitor.visit_IfcKs|j�|j�dS)N)rLr5r)rrrrrrreszFrameSymbolVisitor.visit_MacrocKs |j|f|�|j�|j�dS)N)rcrLr5r#)rrrrrr�visit_ImportszFrameSymbolVisitor.visit_ImportcKsJ|j|f|�x6|jD],}t|t�r6|j�|d�q|j�|�qWdS)Nr)rc�names�
isinstance�tuplerLr5)rrrrrrr�visit_FromImports

z#FrameSymbolVisitor.visit_FromImportcKs$|j|jf|�|j|jf|�dS)z'Visit assignments in the correct order.N)rrr#)rrrrrr�visit_AssignszFrameSymbolVisitor.visit_AssigncKs|j|jf|�dS)zqVisiting stops at for blocks.  However the block sequence
        is visited as part of the outer scope.
        N)r�iter)rrrrrrr]#szFrameSymbolVisitor.visit_ForcKs|j|jf|�dS)N)rrS)rrrrrrrT)sz"FrameSymbolVisitor.visit_CallBlockcKs|j|jf|�dS)N)r�filter)rrrrrrrf,sz$FrameSymbolVisitor.visit_FilterBlockcKsx|jD]}|�|�qWdS)N)�valuesr)rrrr#rrrr_/szFrameSymbolVisitor.visit_WithcKs|j|jf|�dS)zStop visiting at block assigns.N)rr#)rrrrrrrR3sz$FrameSymbolVisitor.visit_AssignBlockcKsdS)zStop visiting at scopes.Nr)rrrrrrrg7szFrameSymbolVisitor.visit_ScopecKsdS)zStop visiting at blocks.Nr)rrrrrrrd:szFrameSymbolVisitor.visit_BlockcKsdS)z!Do not visit into overlay scopes.Nr)rrrrrrrU=sz%FrameSymbolVisitor.visit_OverlayScope)F)'rBrCrD�__doc__rr�Name�boolr*rHrnZNSRefroZIfrhZMacroreZImportrsZ
FromImportrwZAssignrxrlr]rjrTZFilterBlockrfrmr_rirRZScopergZBlockrdrkrUrrrrr�s$		r)N)N)�typingr*�rrrr6r8r3r4rrrGrErrrrrrrrr�<module>s	:

?>