U
    ,º]P  ã                "   @   sê   d Z ddlmZ ddlmZmZmZmZ ddlm	Z
 ddlmZ ddlmZmZ ddl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)œ!Zd*Zd+Zd,Zd-Zd.Zd/Zd0Zd1Zd2Zd3Zd4d5„ ZG d6d7„ d7ejƒZd8S )9z8
Fixer for standard library imports renamed in Python 3
é    )Ú
fixer_base)ÚNameÚis_probably_builtinÚNewlineÚdoes_tree_import)Úpython_symbols)Útoken)ÚNodeÚLeaf©Útouch_import_topÚreprÚ_winregÚConfigParserZcopy_regZQueueZSocketServerZ
markupbaseztest.test_supportZdbhashZdbmZdumbdbmZgdbmZ
HTMLParserZhtmlentitydefsZhttplibZCookieZ	cookielibZDialogZFixTkZScrolledTextZTixZTkconstantsZTkdndZTkinterZtkColorChooserZtkCommonDialogZtkFontZttkZtkMessageBoxZturtleZrobotparserZ	xmlrpclibZ__builtin__)!ÚreprlibÚwinregÚconfigparserÚcopyregZqueueZsocketserverZ_markupbaseztest.supportzdbm.bsdzdbm.ndbmzdbm.dumbzdbm.gnuzhtml.parserzhtml.entitieszhttp.clientzhttp.cookieszhttp.cookiejarztkinter.dialogztkinter._fixztkinter.scrolledtextztkinter.tixztkinter.constantsztkinter.dndztkinter.__init__ztkinter.colorchooserztkinter.commondialogztkinter.fontztkinter.ttkztkinter.messageboxztkinter.turtlezurllib.robotparserzxmlrpc.clientÚbuiltinsz	name='%s'z	attr='%s'z$dotted_name=dotted_name< %s '.' %s >z%sz"power< %s trailer< '.' %s > any* >zpower< %s any* >z:from_import=import_from< 'from' %s 'import' imported=any >z®from_import_submod=import_from< 'from' %s 'import' (%s | import_as_name< %s 'as' renamed=any > | import_as_names< any* (%s | import_as_name< %s 'as' renamed=any >) any* > ) >zrname_import=import_name< 'import' %s > | name_import=import_name< 'import' dotted_as_name< %s 'as' renamed=any > >zAname_import=import_name< 'import' dotted_as_names< names=any* > >c           
      C   sº   d| kr‚|   dd¡\} }t|  }t| }t||f }t| }t|||||f }t||f }t||f }t| }	d 	|||||	f¡S t|  }t||f }t| }t
| }d 	|||f¡S dS )z«
    Accepts a string and returns a pattern of possible patterns involving that name
    Called by simple_mapping_to_pattern for each name in the mapping it receives.
    Ú.é   ú | 
N)ÚsplitÚsimple_name_matchÚsubname_matchÚdotted_name_matchÚfrom_import_matchÚfrom_import_submod_matchÚname_import_matchÚpower_twoname_matchÚpower_subname_matchÚjoinÚpower_onename_match)
ÚnameÚattrZsimple_nameZsimple_attrZdotted_nameZi_fromZi_from_submodZi_nameZu_nameZ	u_subname© r%   úA/usr/lib/python3/dist-packages/libpasteurize/fixes/fix_imports.pyÚall_patternsO   s     r'   c                   @   s6   e Zd Zd dd„ eD ƒ¡Zd eef¡Zdd„ ZdS )Ú
FixImportsr   c                 C   s   g | ]}t |ƒ‘qS r%   )r'   )Ú.0r#   r%   r%   r&   Ú
<listcomp>l   s     zFixImports.<listcomp>c                 C   s   t dd|ƒ d S )NZfutureZstandard_libraryr   )ÚselfZnodeZresultsr%   r%   r&   Ú	transformo   s    zFixImports.transformN)Ú__name__Ú
__module__Ú__qualname__r!   ÚMAPPINGZPATTERNÚmultiple_name_import_matchr,   r%   r%   r%   r&   r(   j   s   r(   N) Ú__doc__Zlib2to3r   Zlib2to3.fixer_utilr   r   r   r   Zlib2to3.pygramr   ZsymsZlib2to3.pgen2r   Zlib2to3.pytreer	   r
   Zlibfuturize.fixer_utilr   r0   r   r   r   r"   r   r    r   r   r   r1   r'   ZBaseFixr(   r%   r%   r%   r&   Ú<module>   sh   ß,