B
    v9a°  ã               @   sf   d dl mZ d dl mZ d dl mZ d dlmZmZmZ d dl mZ ejdhB Z	G dd„ dej
ƒZd	S )
é   )Úpytree)Úpatcomp)Ú
fixer_base)ÚNameÚCallÚDot)Ú
fixer_utilÚiterc               @   s@   e Zd ZdZdZdd„ ZdZe e¡Z	dZ
e e
¡Zdd„ Zd	S )
ÚFixDictTa  
    power< head=any+
         trailer< '.' method=('keys'|'items'|'values'|
                              'iterkeys'|'iteritems'|'itervalues'|
                              'viewkeys'|'viewitems'|'viewvalues') >
         parens=trailer< '(' ')' >
         tail=any*
    >
    c          	   C   s  |d }|d d }|d }| j }|j}| d¡}| d¡}	|sD|	rP|dd … }dd	„ |D ƒ}d
d	„ |D ƒ}| o||  ||¡}
|t |jtƒ t||j	dg¡|d  
¡ g }t |j|¡}|
sà|	sàd|_	tt|rÔdndƒ|gƒ}|røt |j|g| ¡}|j	|_	|S )NÚheadÚmethodé    Útailr	   Zviewé   c             S   s   g | ]}|  ¡ ‘qS © )Úclone)Ú.0Únr   r   ú/usr/lib/python3.7/fix_dict.pyú
<listcomp>A   s    z%FixDict.transform.<locals>.<listcomp>c             S   s   g | ]}|  ¡ ‘qS r   )r   )r   r   r   r   r   r   B   s    )ÚprefixZparensÚ Úlist)ÚsymsÚvalueÚ
startswithÚin_special_contextr   ZNodeZtrailerr   r   r   r   Zpowerr   )ÚselfÚnodeÚresultsr   r   r   r   Zmethod_nameÚisiterZisviewZspecialÚargsÚnewr   r   r   Ú	transform6   s2    


zFixDict.transformz3power< func=NAME trailer< '(' node=any ')' > any* >zmfor_stmt< 'for' any 'in' node=any ':' any* >
            | comp_for< 'for' any 'in' node=any any* >
         c             C   s‚   |j d krdS i }|j j d k	r^| j |j j |¡r^|d |kr^|rN|d jtkS |d jtjkS |sfdS | j |j |¡o€|d |kS )NFr   Úfunc)ÚparentÚp1Úmatchr   Úiter_exemptr   Úconsuming_callsÚp2)r   r   r    r   r   r   r   r   Z   s    
zFixDict.in_special_contextN)Ú__name__Ú
__module__Ú__qualname__ZBM_compatibleZPATTERNr#   ZP1r   Zcompile_patternr&   ZP2r*   r   r   r   r   r   r
   )   s   


r
   N)r   r   r   r   r   r   r   r   r)   r(   ZBaseFixr
   r   r   r   r   Ú<module>   s   