a
    ze4                  1   @   s   d Z ddlmZ ddlmZmZ ddddddd	d
dddddddddddddddddddddddd d!d"d"d#d$d%d&d'd(d(d(d)d*d*d+d,d-0Zd.d/ Zefd0d1ZG d2d3 d3ej	Z
d4S )5z/Fix incompatible imports and module references.   )
fixer_base)Name
attr_chainiopicklebuiltinscopyregqueuesocketserverconfigparserreprlibztkinter.filedialogztkinter.simpledialogztkinter.colorchooserztkinter.commondialogztkinter.dialogztkinter.dndztkinter.fontztkinter.messageboxztkinter.scrolledtextztkinter.constantsztkinter.tixztkinter.ttktkinter_markupbasewinreg_thread_dummy_threadzdbm.bsdzdbm.dumbzdbm.ndbmzdbm.gnuzxmlrpc.clientzxmlrpc.serverzhttp.clientzhtml.entitieszhtml.parserzhttp.cookieszhttp.cookiejarzhttp.server
subprocesscollectionszurllib.parsezurllib.robotparser)0StringIO	cStringIOcPickle__builtin__copy_regQueueSocketServerConfigParserrepr
FileDialogtkFileDialogSimpleDialogtkSimpleDialogtkColorChoosertkCommonDialogDialogTkdndtkFonttkMessageBoxScrolledTextTkconstantsTixttkTkinter
markupbase_winregthreaddummy_threaddbhashdumbdbmdbmgdbm	xmlrpclibDocXMLRPCServerSimpleXMLRPCServerhttplibhtmlentitydefs
HTMLParserCookie	cookielibBaseHTTPServerSimpleHTTPServerCGIHTTPServercommands
UserStringUserListurlparserobotparserc                 C   s   dd tt|  d S )N(|))joinmapr   )members rJ   //usr/lib/python3.9/lib2to3/fixes/fix_imports.py
alternates=   s    rL   c                 c   sT   d dd | D }t|  }d||f V  d| V  d||f V  d| V  d S )Nz | c                 S   s   g | ]}d | qS )zmodule_name='%s'rJ   ).0keyrJ   rJ   rK   
<listcomp>B       z!build_pattern.<locals>.<listcomp>zyname_import=import_name< 'import' ((%s) |
               multiple_imports=dotted_as_names< any* (%s) any* >) >
          zimport_from< 'from' (%s) 'import' ['(']
              ( any | import_as_name< any 'as' any > |
                import_as_names< any* >)  [')'] >
          zimport_name< 'import' (dotted_as_name< (%s) 'as' any > |
               multiple_imports=dotted_as_names<
                 any* dotted_as_name< (%s) 'as' any > any* >) >
          z3power< bare_with_attr=(%s) trailer<'.' any > any* >)rG   rL   keys)mappingZmod_listZ
bare_namesrJ   rJ   rK   build_patternA   s    rS   c                       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 )
FixImportsT   c                 C   s   d t| jS )NrE   )rG   rS   rR   selfrJ   rJ   rK   rS   `   s    zFixImports.build_patternc                    s   |   | _tt|   d S N)rS   ZPATTERNsuperrT   compile_patternrV   	__class__rJ   rK   rZ   c   s    
zFixImports.compile_patternc                    sH   t t| j  |}|rDd|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 rX   rJ   )rM   objmatchrJ   rK   	<genexpr>q   rP   z#FixImports.match.<locals>.<genexpr>parentF)rY   rT   r`   anyr   )rW   noderesultsr[   r_   rK   r`   j   s    zFixImports.matchc                    s   t t| || i | _d S rX   )rY   rT   
start_treereplace)rW   Ztreefilenamer[   rJ   rK   rf   v   s    zFixImports.start_treec                 C   s   | d}|rh|j}| j| }|t||jd d|v rD|| j|< d|v r| |}|r| || n2|d d }| j |j}|r|t||jd d S )Nmodule_name)prefixZname_importZmultiple_importsr]       )getvaluerR   rg   r   rj   r`   	transform)rW   rd   re   Z
import_modZmod_namenew_nameZ	bare_namerJ   rJ   rK   rn   z   s    



zFixImports.transform)__name__
__module____qualname__ZBM_compatibleZkeep_line_orderMAPPINGrR   Z	run_orderrS   rZ   r`   rf   rn   __classcell__rJ   rJ   r[   rK   rT   U   s   rT   N)__doc__ r   Z
fixer_utilr   r   rs   rL   rS   ZBaseFixrT   rJ   rJ   rJ   rK   <module>   sl   5