a
    X%bs
                     @   s>   d Z ddlmZmZ ddlmZ g dZG dd dejZdS )	z
Warn about features that are not present in Python 2.5, giving a message that
points to the earliest version of Python 2.x (or 3.x, if none) that supports it
   )FeatureFeatures    )
fixer_base))
memoryviewz4power < 'memoryview' trailer < '(' any* ')' > any* >z2.7)Znumberszimport_from< 'from' 'numbers' 'import' any* > |
           import_name< 'import' ('numbers' dotted_as_names< any* 'numbers' any* >) >2.6)abczyimport_name< 'import' ('abc' dotted_as_names< any* 'abc' any* >) > |
           import_from< 'from' 'abc' 'import' any* >r   )iozvimport_name< 'import' ('io' dotted_as_names< any* 'io' any* >) > |
           import_from< 'from' 'io' 'import' any* >r   )binz+power< 'bin' trailer< '(' any* ')' > any* >r   )Z
formattingz<power< any trailer< '.' 'format' > trailer< '(' any* ')' > >r   )nonlocalzglobal_stmt< 'nonlocal' any* >3.0)with_tracebackztrailer< '.' 'with_traceback' >r   c                       sF   e Zd ZdZe Zedd eD Zej	Z	 fddZ
dd Z  ZS )FixFeatures	   c                 C   s   g | ]\}}}t |||qS  )r   ).0namepatternversionr   r   p/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/libpasteurize/fixes/fix_features.py
<listcomp>;   s   zFixFeatures.<listcomp>c                    s2   t t| |}z
|d= W n ty,   Y n0 |S )Nnode)superr   match	Exception)selfr   Zto_ret	__class__r   r   r   @   s    
zFixFeatures.matchc                 C   sZ   |D ]P}|| j v rqq| j| }|jdkr2| j}n| j}||| d | j | qd S )N3)reason)features_warnedfeaturesr   Zcannot_convertwarningZmessage_textadd)r   r   resultsZfeature_nameZcurr_featureZfailr   r   r   	transformK   s    


zFixFeatures.transform)__name__
__module____qualname__Z	run_ordersetr    r   FEATURESr!   ZPATTERNr   r%   __classcell__r   r   r   r   r   3   s   r   N)	__doc__Zfeature_baser   r   Zlib2to3r   r*   ZBaseFixr   r   r   r   r   <module>   s   *