o
    ,º]   ã                   @   sP   d Z ddlmZ ddlmZmZ ddlmZmZm	Z	 ddiZ
G dd„ de	ƒZd	S )
zCFix UserDict.

Incomplete!

TODO: base this on fix_urllib perhaps?
é    )Ú
fixer_base)ÚNameÚ
attr_chain)Ú
alternatesÚbuild_patternÚ
FixImportsÚUserDictÚcollectionsc                       sT   e Zd ZdZdZeZdZdd„ Z‡ fdd„Z	‡ fdd„Z
‡ fd	d
„Zdd„ Z‡  ZS )ÚFixUserdictTé   c                 C   s   d  t| jƒ¡S )Nú|)Újoinr   Úmapping©Úself© r   ú[/var/www/html/myproject/venv/lib/python3.10/site-packages/libfuturize/fixes/fix_UserDict.pyr   5   s   zFixUserdict.build_patternc                    s   |   ¡ | _tt| ƒ ¡  d S ©N)r   ÚPATTERNÚsuperr   Úcompile_patternr   ©Ú	__class__r   r   r   8   s   
zFixUserdict.compile_patternc                    sH   t t| ƒj‰ ˆ |ƒ}|r"d|vr t‡ fdd„t|dƒD ƒƒr dS |S dS )NÚbare_with_attrc                 3   s   � | ]}ˆ |ƒV  qd S r   r   )Ú.0Úobj©Úmatchr   r   Ú	<genexpr>F   s   € z$FixUserdict.match.<locals>.<genexpr>ÚparentF)r   r   r   Úanyr   )r   ÚnodeÚresultsr   r   r   r   ?   s   ÿzFixUserdict.matchc                    s   t t| ƒ ||¡ i | _d S r   )r   r   Ú
start_treeÚreplace)r   ÚtreeÚfilenamer   r   r   r#   K   s   
zFixUserdict.start_treec                 C   s°   |  d¡}|r;|j}t| j| ƒ}| t||jd�¡ d|v r$|| j|< d|v r7|  |¡}|r9|  ||¡ d S d S d S |d d }| j  |j¡}|rV| t||jd�¡ d S d S )NÚmodule_name)ÚprefixÚname_importÚmultiple_importsr   r   )	ÚgetÚvalueÚunicoder   r$   r   r(   r   Ú	transform)r   r!   r"   Ú
import_modÚmod_nameÚnew_nameÚ	bare_namer   r   r   r.   O   s$   


ùÿzFixUserdict.transform)Ú__name__Ú
__module__Ú__qualname__ÚBM_compatibleÚkeep_line_orderÚMAPPINGr   Ú	run_orderr   r   r   r#   r.   Ú__classcell__r   r   r   r   r
   *   s    r
   N)Ú__doc__Úlib2to3r   Úlib2to3.fixer_utilr   r   Úlib2to3.fixes.fix_importsr   r   r   r8   r
   r   r   r   r   Ú<module>   s    	