U
    h                     @   s0   d Z dZdZG dd deZG dd deZdS )z
Base classes for features that are backwards-incompatible.

Usage:
features = Features()
features.add(Feature("py3k_feature", "power< 'py3k' any* >", "2.7"))
PATTERN = features.PATTERN
z%s=%sz-
%s is only supported in Python %s and above.c                   @   s    e Zd ZdZdd Zdd ZdS )Featurez
    A feature has a name, a pattern, and a minimum version of Python 2.x
    required to use the feature (or 3.x if there is no backwards-compatible
    version of 2.x)
    c                 C   s   || _ || _|| _d S )N)name_patternversion)selfr   PATTERNr    r   R/var/www/html/venv/lib/python3.8/site-packages/libpasteurize/fixes/feature_base.py__init__   s    zFeature.__init__c                 C   s   t | j| jf S )zS
        Format the above text with the name and minimum version required.
        )message_unformattedr   r   r   r   r   r   message_text   s    zFeature.message_textN)__name__
__module____qualname____doc__r	   r   r   r   r   r   r      s   r   c                   @   s0   e Zd ZdZi Zdd Zedd Zdd ZdS )	Featuresz
    A set of features that generates a pattern for the features it contains.
    This set will act like a mapping in that we map names to patterns.
    c                 C   s   t dd t| D | _dS )zS
        Called every time we care about the mapping of names to features.
        c                 S   s   g | ]}|j |fqS r   )r   .0fr   r   r   
<listcomp>*   s     z+Features.update_mapping.<locals>.<listcomp>N)dictitermappingr   r   r   r   update_mapping&   s    zFeatures.update_mappingc                 C   s    |    ddd t| D S )z{
        Uses the mapping of names to features to return a PATTERN suitable
        for using the lib2to3 patcomp.
        z |
c                 S   s   g | ]}t |j|jf qS r   )pattern_unformattedr   r   r   r   r   r   r   3   s     z$Features.PATTERN.<locals>.<listcomp>)r   joinr   r   r   r   r   r   ,   s    zFeatures.PATTERNc                 C   s
   | j | S )zH
        Implement a simple mapping to get patterns from names.
        )r   )r   keyr   r   r   __getitem__5   s    zFeatures.__getitem__N)	r   r   r   r   r   r   propertyr   r   r   r   r   r   r      s   
r   N)r   r   r
   objectr   setr   r   r   r   r   <module>   s   	