ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/lib2to3/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/lib2to3/__pycache__/pytree.cpython-35.opt-2.pyc



���]�m�@sdZddlZddlZddlmZdZiadd�ZGdd�de�Z	Gd	d
�d
e	�Z
Gdd�de	�Zd
d�ZGdd�de�Z
Gdd�de
�ZGdd�de
�ZGdd�de
�ZGdd�de
�Zdd�ZdS)z#Guido van Rossum <guido@python.org>�N)�StringIOi���cCsbtsRddlm}x9|jj�D](\}}t|�tkr&|t|<q&Wtj||�S)N�)�python_symbols)�_type_reprsZpygramr�__dict__�items�type�int�
setdefault)Ztype_numr�name�val�r
�+/opt/alt/python35/lib64/python3.5/pytree.py�	type_reprsrc@seZdZdZdZfZdZdZdd�Zdd�Z	dZ
dd�Zd	d
�Zdd�Z
d
d�Zdd�Zdd�Zdd�Zdd�Zedd��Zedd��Zdd�Zdd�Zdd �Zejd%krd#d$�ZdS)&�BaseNFcOs
tj|�S)N)�object�__new__)�cls�args�kwdsr
r
rr2szBase.__new__cCs#|j|jk	rtS|j|�S)N)�	__class__�NotImplemented�_eq)�self�otherr
r
r�__eq__7szBase.__eq__cCs
t�dS)N)�NotImplementedError)rrr
r
rrCs	zBase._eqcCs
t�dS)N)r)rr
r
r�cloneNsz
Base.clonecCs
t�dS)N)r)rr
r
r�
post_orderVszBase.post_ordercCs
t�dS)N)r)rr
r
r�	pre_order^szBase.pre_ordercCs�t|t�s|g}g}d}xO|jjD]A}||kre|dk	r\|j|�d}q1|j|�q1W|jj�||j_x|D]}|j|_q�Wd|_dS)NFT)�
isinstance�list�parent�children�extend�append�changed)r�newZ
l_children�found�ch�xr
r
r�replacefs	
	

zBase.replacecCs=|}x-t|t�s5|js%dS|jd}q	W|jS)Nr)r �Leafr#�lineno)r�noder
r
r�
get_lineno}s	zBase.get_linenocCs#|jr|jj�d|_dS)NT)r"r&�was_changed)rr
r
rr&�s	
zBase.changedcCsc|jr_xSt|jj�D]?\}}||kr|jj�|jj|=d|_|SqWdS)N)r"�	enumerater#r&)r�ir.r
r
r�remove�s	

	zBase.removecCsu|jdkrdSx[t|jj�D]G\}}||kr&y|jj|dSWq&tk
rldSYq&Xq&WdS)Nr)r"r1r#�
IndexError)rr2�childr
r
r�next_sibling�s
zBase.next_siblingcCsh|jdkrdSxNt|jj�D]:\}}||kr&|dkrNdS|jj|dSq&WdS)Nrr)r"r1r#)rr2r5r
r
r�prev_sibling�szBase.prev_siblingccs'x |jD]}|j�EdHq
WdS)N)r#�leaves)rr5r
r
rr8�szBase.leavescCs$|jdkrdSd|jj�S)Nrr)r"�depth)rr
r
rr9�sz
Base.depthcCs |j}|dkrdS|jS)N�)r6�prefix)rZnext_sibr
r
r�
get_suffix�s	zBase.get_suffix�rcCst|�jd�S)N�ascii)�str�encode)rr
r
r�__str__�szBase.__str__)r=r)�__name__�
__module__�__qualname__rr"r#r0Zwas_checkedrr�__hash__rrrrr+r/r&r3�propertyr6r7r8r9r<�sys�version_inforAr
r
r
rr s.
	

rc@s�eZdZddddd�Zdd�Zdd�ZejdkrNeZd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zee
e�Zdd�Zdd�Zdd�ZdS)�NodeNcCss||_t|�|_x|jD]}||_q"W|dk	rJ||_|rf|dd�|_n	d|_dS)N)rr!r#r"r;�fixers_applied)rrr#�contextr;rJr)r
r
r�__init__�s
	
	z
Node.__init__cCs#d|jjt|j�|jfS)Nz
%s(%s, %r))rrBrrr#)rr
r
r�__repr__�sz
Node.__repr__cCsdjtt|j��S)Nr:)�join�mapr?r#)rr
r
r�__unicode__�szNode.__unicode__r=rcCs"|j|jf|j|jfkS)N)rr#)rrr
r
rr�szNode._eqcCs)t|jdd�|jD�d|j�S)NcSsg|]}|j��qSr
)r)�.0r)r
r
r�
<listcomp>s	zNode.clone.<locals>.<listcomp>rJ)rIrr#rJ)rr
r
rrsz
Node.cloneccs,x |jD]}|j�EdHq
W|VdS)N)r#r)rr5r
r
rrszNode.post_orderccs,|Vx |jD]}|j�EdHqWdS)N)r#r)rr5r
r
rr
szNode.pre_ordercCs|js
dS|jdjS)Nr:r)r#r;)rr
r
r�_prefix_getters	zNode._prefix_gettercCs|jr||jd_dS)Nr)r#r;)rr;r
r
r�_prefix_setters	zNode._prefix_settercCs4||_d|j|_||j|<|j�dS)N)r"r#r&)rr2r5r
r
r�	set_child!s	
zNode.set_childcCs*||_|jj||�|j�dS)N)r"r#�insertr&)rr2r5r
r
r�insert_child+s	zNode.insert_childcCs'||_|jj|�|j�dS)N)r"r#r%r&)rr5r
r
r�append_child4s	zNode.append_child)r=r)rBrCrDrLrMrPrGrHrArrrrrSrTrFr;rUrWrXr
r
r
rrI�s"
	rIc@s�eZdZdZdZdZddgdd�Zdd�Zdd	�Ze	j
dkr`eZdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zeee�ZdS)r,r:rNcCse|dk	r'|\|_\|_|_||_||_|dk	rN||_|dd�|_dS)N)�_prefixr-�columnr�valuerJ)rrr[rKr;rJr
r
rrLGs			z
Leaf.__init__cCsd|jj|j|jfS)Nz
%s(%r, %r))rrBrr[)rr
r
rrMZsz
Leaf.__repr__cCs|jt|j�S)N)r;r?r[)rr
r
rrP`szLeaf.__unicode__r=cCs"|j|jf|j|jfkS)N)rr[)rrr
r
rrkszLeaf._eqcCs4t|j|j|j|j|jffd|j�S)NrJ)r,rr[r;r-rZrJ)rr
r
rrosz
Leaf.cloneccs	|VdS)Nr
)rr
r
rr8uszLeaf.leavesccs	|VdS)Nr
)rr
r
rrxszLeaf.post_orderccs	|VdS)Nr
)rr
r
rr|szLeaf.pre_ordercCs|jS)N)rY)rr
r
rrS�szLeaf._prefix_gettercCs|j�||_dS)N)r&rY)rr;r
r
rrT�s
zLeaf._prefix_setter)r=r)rBrCrDrYr-rZrLrMrPrGrHrArrr8rrrSrTrFr;r
r
r
rr,>s$r,cCsk|\}}}}|s'||jkrTt|�dkrA|dSt||d|�St||d|�SdS)NrrrK)Z
number2symbol�lenrIr,)ZgrZraw_noderr[rKr#r
r
r�convert�sr]c@speZdZdZdZdZdd�Zdd�Zdd�Zddd	�Z	dd
d�Z
dd
�ZdS)�BasePatternNcOs
tj|�S)N)rr)rrrr
r
rr�szBasePattern.__new__cCsht|j�|j|jg}x!|rA|ddkrA|d=q!Wd|jjdjtt|��fS)Nrz%s(%s)z, ���r_)	rr�contentrrrBrNrO�repr)rrr
r
rrM�szBasePattern.__repr__cCs|S)Nr
)rr
r
r�optimize�szBasePattern.optimizecCs�|jdk	r%|j|jkr%dS|jdk	rud}|dk	rLi}|j||�sbdS|ru|j|�|dk	r�|jr�|||j<dS)NFT)rr`�	_submatch�updater)rr.�results�rr
r
r�match�s!

zBasePattern.matchcCs*t|�dkrdS|j|d|�S)NrFr)r\rg)r�nodesrer
r
r�	match_seq�szBasePattern.match_seqccs1i}|r-|j|d|�r-d|fVdS)Nrr)rg)rrhrfr
r
r�generate_matches�szBasePattern.generate_matches)rBrCrDrr`rrrMrbrgrirjr
r
r
rr^�s
r^c@sCeZdZddddd�Zddd�Zddd�ZdS)�LeafPatternNcCs7|dk	r|dk	r||_||_||_dS)N)rr`r)rrr`rr
r
rrL�s
		zLeafPattern.__init__cCs&t|t�sdStj|||�S)NF)r r,r^rg)rr.rer
r
rrgszLeafPattern.matchcCs|j|jkS)N)r`r[)rr.rer
r
rrcs
zLeafPattern._submatch)rBrCrDrLrgrcr
r
r
rrk�srkc@s:eZdZdZddddd�Zddd�ZdS)�NodePatternFNcCsx|dk	r|dk	rYt|�}x2t|�D]$\}}t|t�r1d|_q1W||_||_||_dS)NT)r!r1r �WildcardPattern�	wildcardsrr`r)rrr`rr2�itemr
r
rrL%s
		zNodePattern.__init__cCs�|jrexUt|j|j�D]>\}}|t|j�kr|dk	rY|j|�dSqWdSt|j�t|j�kr�dSx9t|j|j�D]"\}}|j||�s�dSq�WdS)NTF)rnrjr`r#r\rd�ziprg)rr.re�crf�
subpatternr5r
r
rrcBs
	"
"zNodePattern._submatch)rBrCrDrnrLrcr
r
r
rrl!srlc@s�eZdZddeddd�Zdd�Zddd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)rmNrcCsZ|dk	r2ttt|��}x|D]}q(W||_||_||_||_dS)N)�tuplerOr`�min�maxr)rr`rtrur�altr
r
rrLls
			zWildcardPattern.__init__cCs)d}|jdk	rTt|j�dkrTt|jd�dkrT|jdd}|jdkr�|jdkr�|jdkr�td|j�S|dk	r�|j|jkr�|j�S|jdkr%t|t�r%|jdkr%|j|jkr%t|j|j|j|j|j|j�S|S)Nrrr)	r`r\rtrurlrrbr rm)rrrr
r
rrb�s .
!	


zWildcardPattern.optimizecCs|j|g|�S)N)ri)rr.rer
r
rrg�szWildcardPattern.matchcCsoxh|j|�D]W\}}|t|�kr|dk	rc|j|�|jrct|�||j<dSqWdS)NTF)rjr\rdrr!)rrhrerqrfr
r
rri�s
	zWildcardPattern.match_seqccs�|jdkrvxzt|jdtt|�|j��D]7}i}|jrd|d|�||j<||fVq8Wn|jdkr�|j|�Vn�ttd�r�tj	}t
�t_	z�yRxK|j|d�D]7\}}|jr�|d|�||j<||fVq�WWn]tk
rnxH|j
|�D]7\}}|jr[|d|�||j<||fVq/WYnXWdttd�r�|t_	XdS)NrZ	bare_name�getrefcountr)r`�rangertr\rur�_bare_name_matches�hasattrrG�stderrr�_recursive_matches�RuntimeError�_iterative_matches)rrh�countrfZsave_stderrr
r
rrj�s./			
	z WildcardPattern.generate_matchesccs]t|�}d|jkr&difVg}xO|jD]D}x;t||�D]*\}}||fV|j||f�qLWq6Wx�|rXg}x�|D]�\}}	||kr�||jkr�x�|jD]�}xyt|||d��D]^\}
}|
dkr�i}|j|	�|j|�||
|fV|j||
|f�q�Wq�Wq�W|}q�WdS)Nr)r\rtr`rjr%rurd)rrhZnodelenrervrqrfZnew_results�c0�r0�c1�r1r
r
rr~�s*	&

#z"WildcardPattern._iterative_matchescCs�d}i}d}t|�}x\|r|||kr|d}x<|jD]1}|dj|||�rD|d7}d}PqDWq!W|d|�||j<||fS)NrFTr)r\r`rgr)rrhrrf�doneruZleafr
r
rry�s
	z"WildcardPattern._bare_name_matchesc	cs�||jkrdifV||jkr�x�|jD]�}x}t||�D]l\}}x]|j||d�|d�D];\}}i}|j|�|j|�|||fVqvWqIWq3WdS)Nrr)rtrur`rjr|rd)	rrhrrvr�r�r�r�rfr
r
rr|s-

z"WildcardPattern._recursive_matches)rBrCrD�HUGErLrbrgrirjr~ryr|r
r
r
rrm^s#-rmc@sCeZdZddd�Zdd�Zdd�Zdd	�ZdS)
�NegatedPatternNcCs|dk	r||_dS)N)r`)rr`r
r
rrLs	zNegatedPattern.__init__cCsdS)NFr
)rr.r
r
rrg)szNegatedPattern.matchcCst|�dkS)Nr)r\)rrhr
r
rri-szNegatedPattern.match_seqccsb|jdkr/t|�dkr^difVn/x!|jj|�D]
\}}dSWdifVdS)Nr)r`r\rj)rrhrqrfr
r
rrj1szNegatedPattern.generate_matches)rBrCrDrLrgrirjr
r
r
rr�s
r�c	cs�|sdifVn�|d|dd�}}x�|j|�D]y\}}|s_||fVq?xVt|||d��D];\}}i}|j|�|j|�|||fVqyWq?WdS)Nrr)rjrd)	�patternsrh�p�restr�r�r�r�rfr
r
rrj=s
&

rj)�
__author__rG�warnings�iorr�rrrrrIr,r]r^rkrlrmr�rjr
r
r
r�<module>
s 
�nNV,=�#

Zerion Mini Shell 1.0