a
    ³yjcÚ  ã                   @   sj   d Z ddlmZmZmZmZ er2ddlmZmZ ne ZZeee	 dœdd„Z
eeeef dœd	d
„ZdS )z)
Compatibility layer with Python 3.8/3.9
é    )ÚTYPE_CHECKINGÚAnyÚOptionalÚTupleé   )ÚDistributionÚ
EntryPoint)ÚdistÚreturnc              	   C   sH   z| j W S  tyB   ddlm} | t| ddƒp:| jd ¡ Y S 0 dS )z]
    Honor name normalization for distributions that don't provide ``_normalized_name``.
    r   )ÚPreparedÚnameNÚName)Z_normalized_nameÚAttributeErrorÚ r   Ú	normalizeÚgetattrÚmetadata)r	   r   © r   úZ/var/www/html/django/DPS/env/lib/python3.9/site-packages/importlib_metadata/_py39compat.pyÚnormalized_name   s
    r   )Úepr
   c                 K   s`   z| | j f i |¤ŽfW S  tyZ   ddlm} || j| j| jƒ}||j f i |¤Žf Y S 0 dS )aª  
    Workaround for ``EntryPoint`` objects without the ``matches`` method.
    For the sake of convenience, a tuple is returned containing not only the
    boolean value corresponding to the predicate evalutation, but also a compatible
    ``EntryPoint`` object that can be safely used at a later stage.

    For example, the following sequences of expressions should be compatible:

        # Sequence 1: using the compatibility layer
        candidates = (_py39compat.ep_matches(ep, **params) for ep in entry_points)
        [ep for ep, predicate in candidates if predicate]

        # Sequence 2: using Python 3.9+
        [ep for ep in entry_points if ep.matches(**params)]
    r   )r   N)Úmatchesr   r   r   r   ÚvalueÚgroup)r   Úparamsr   Z_epr   r   r   Ú
ep_matches   s    r   N)Ú__doc__Útypingr   r   r   r   r   r   r   Ústrr   Úboolr   r   r   r   r   Ú<module>   s   