o
    |ŸŽiê  ã                   @   sî   d dl Zd dlZd dlZd dlZd dlmZmZmZm	Z	m
Z
mZmZmZ d dlmZ d dlmZmZ d dlmZmZmZ d dlmZ erQd dlmZ d dlmZ neZeeef Ze e¡Z G d	d
„ d
eƒZ!G dd„ deƒZ"G dd„ dƒZ#dS )é    N)ÚTYPE_CHECKINGÚ
CollectionÚ	ContainerÚIterableÚIteratorÚListÚOptionalÚUnion)ÚRequirement)ÚLegacyVersionÚVersion)ÚDIRECT_URL_METADATA_NAMEÚ	DirectUrlÚDirectUrlValidationError)Ústdlib_pkgs)ÚProtocol)ÚNormalizedNamec                   @   sB   e Zd Zedefdd„ƒZedefdd„ƒZedefdd„ƒZdS )	ÚBaseEntryPointÚreturnc                 C   ó   t ƒ ‚©N©ÚNotImplementedError©Úself© r   úeC:\Users\psant\Downloads\Anu Raj Backend\school\venv\Lib\site-packages\pip/_internal/metadata/base.pyÚname'   ó   zBaseEntryPoint.namec                 C   r   r   r   r   r   r   r   Úvalue+   r   zBaseEntryPoint.valuec                 C   r   r   r   r   r   r   r   Úgroup/   r   zBaseEntryPoint.groupN)Ú__name__Ú
__module__Ú__qualname__ÚpropertyÚstrr   r   r    r   r   r   r   r   &   s    r   c                   @   sF  e Zd Zedee fdd„ƒZedee fdd„ƒZed'dd„ƒZede	fd	d
„ƒZ
edee fdd„ƒZedefdd„ƒZedefdd„ƒZedefdd„ƒZedefdd„ƒZedefdd„ƒZdedefdd„Zdee fdd„Zedejjfdd„ƒZedee fdd„ƒZedefd d!„ƒZd(d#ee dee fd$d%„Zd&S ))ÚBaseDistributionr   c                 C   r   )aÐ  Where the distribution is loaded from.

        A string value is not necessarily a filesystem path, since distributions
        can be loaded from other sources, e.g. arbitrary zip archives. ``None``
        means the distribution is created in-memory.

        Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If
        this is a symbolic link, we want to preserve the relative path between
        it and files in the distribution.
        Nr   r   r   r   r   Úlocation5   s   zBaseDistribution.locationc                 C   r   )a'  Location of the .[egg|dist]-info directory.

        Similarly to ``location``, a string value is not necessarily a
        filesystem path. ``None`` means the distribution is created in-memory.

        For a modern .dist-info installation on disk, this should be something
        like ``{location}/{raw_name}-{version}.dist-info``.

        Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If
        this is a symbolic link, we want to preserve the relative path between
        it and other files in the distribution.
        Nr   r   r   r   r   Úinfo_directoryC   s   zBaseDistribution.info_directoryr   c                 C   r   r   r   r   r   r   r   Úcanonical_nameS   r   zBaseDistribution.canonical_namec                 C   r   r   r   r   r   r   r   ÚversionW   r   zBaseDistribution.versionc              
   C   sr   z|   t¡}W n
 ty   Y dS w zt |¡W S  ttjtfy8 } zt	 
dt| j|¡ W Y d}~dS d}~ww )z¬Obtain a DirectUrl from this distribution.

        Returns None if the distribution has no `direct_url.json` metadata,
        or if `direct_url.json` is invalid.
        NzError parsing %s for %s: %s)Ú	read_textr   ÚFileNotFoundErrorr   Ú	from_jsonÚUnicodeDecodeErrorÚjsonÚJSONDecodeErrorr   ÚloggerÚwarningr)   )r   ÚcontentÚer   r   r   Ú
direct_url[   s*   ÿýü€õzBaseDistribution.direct_urlc                 C   r   r   r   r   r   r   r   Ú	installeru   r   zBaseDistribution.installerc                 C   r   r   r   r   r   r   r   Úeditabley   r   zBaseDistribution.editablec                 C   r   r   r   r   r   r   r   Úlocal}   r   zBaseDistribution.localc                 C   r   r   r   r   r   r   r   Úin_usersite�   r   zBaseDistribution.in_usersitec                 C   r   r   r   r   r   r   r   Úin_site_packages…   r   z!BaseDistribution.in_site_packagesr   c                 C   r   )zªRead a file in the .dist-info (or .egg-info) directory.

        Should raise ``FileNotFoundError`` if ``name`` does not exist in the
        metadata directory.
        Nr   ©r   r   r   r   r   r+   ‰   s   zBaseDistribution.read_textc                 C   r   r   r   r   r   r   r   Úiter_entry_points‘   ó   z"BaseDistribution.iter_entry_pointsc                 C   r   )z?Metadata of distribution parsed from e.g. METADATA or PKG-INFO.Nr   r   r   r   r   Úmetadata”   s   zBaseDistribution.metadatac                 C   s   | j  d¡S )zDValue of "Metadata-Version:" in distribution metadata, if available.zMetadata-VersionN)r>   Úgetr   r   r   r   Úmetadata_version™   s   z!BaseDistribution.metadata_versionc                 C   s   | j  d| j¡S )z*Value of "Name:" in distribution metadata.ÚNameN)r>   r?   r)   r   r   r   r   Úraw_namež   s   zBaseDistribution.raw_namer   Úextrasc                 C   r   r   r   )r   rC   r   r   r   Úiter_dependencies¥   r=   z"BaseDistribution.iter_dependenciesN)r   r   )r   ) r!   r"   r#   r$   r   r%   r'   r(   r)   ÚDistributionVersionr*   r   r5   r6   Úboolr7   r8   r9   r:   r+   r   r   r<   ÚemailÚmessageÚMessager>   r@   rB   r   r
   rD   r   r   r   r   r&   4   s<     r&   c                   @   s¬   e Zd ZdZeddd„ƒZedeee  dd fdd„ƒZ	deded	 fd
d„Z
ded	 fdd„Zded	 fdd„Zdedddfdedee dedededee fdd„ZdS )ÚBaseEnvironmentz6An environment containing distributions to introspect.r   c                 C   r   r   r   )Úclsr   r   r   Údefault¬   r   zBaseEnvironment.defaultÚpathsc                 C   r   r   r   )rK   rM   r   r   r   Ú
from_paths°   r   zBaseEnvironment.from_pathsr   r&   c                 C   r   )z=Given a requirement name, return the installed distributions.Nr   r;   r   r   r   Úget_distribution´   r   z BaseEnvironment.get_distributionc                 C   r   )a  Iterate through installed distributions.

        This function should be implemented by subclass, but never called
        directly. Use the public ``iter_distribution()`` instead, which
        implements additional logic to make sure the distributions are valid.
        Nr   r   r   r   r   Ú_iter_distributions¸   s   z#BaseEnvironment._iter_distributionsc                 c   sF   � |   ¡ D ]}tjd|jtjd�}|st d|j|j¡ q|V  qdS )z(Iterate through installed distributions.z)^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$)Úflagsz%Ignoring invalid distribution %s (%s)N)rP   ÚreÚmatchr)   Ú
IGNORECASEr1   r2   r'   )r   ÚdistÚproject_name_validr   r   r   Úiter_distributionsÁ   s    €ýýïz"BaseEnvironment.iter_distributionsTFÚ
local_onlyÚskipÚinclude_editablesÚeditables_onlyÚ	user_onlyc                    sb   |   ¡ }|rdd„ |D ƒ}|sdd„ |D ƒ}|rdd„ |D ƒ}|r(dd„ |D ƒ}‡ fdd„|D ƒS )a  Return a list of installed distributions.

        :param local_only: If True (default), only return installations
        local to the current virtualenv, if in a virtualenv.
        :param skip: An iterable of canonicalized project names to ignore;
            defaults to ``stdlib_pkgs``.
        :param include_editables: If False, don't report editables.
        :param editables_only: If True, only report editables.
        :param user_only: If True, only report installations in the user
        site directory.
        c                 s   ó   � | ]}|j r|V  qd S r   )r8   ©Ú.0Údr   r   r   Ú	<genexpr>ë   ó   € z?BaseEnvironment.iter_installed_distributions.<locals>.<genexpr>c                 s   s   � | ]}|j s|V  qd S r   ©r7   r^   r   r   r   ra   í   rb   c                 s   r]   r   rc   r^   r   r   r   ra   ï   rb   c                 s   r]   r   )r9   r^   r   r   r   ra   ñ   rb   c                 3   s   � | ]
}|j ˆ vr|V  qd S r   )r)   r^   ©rY   r   r   ra   ò   s   € N)rW   )r   rX   rY   rZ   r[   r\   Úitr   rd   r   Úiter_installed_distributionsÖ   s   z,BaseEnvironment.iter_installed_distributionsN)r   rJ   )r!   r"   r#   Ú__doc__ÚclassmethodrL   r   r   r%   rN   rO   r   rP   rW   r   rF   r   r&   rf   r   r   r   r   rJ   ©   s6    	úþýüûúùrJ   )$Úemail.messagerG   r/   ÚloggingrR   Útypingr   r   r   r   r   r   r   r	   Z"pip._vendor.packaging.requirementsr
   Zpip._vendor.packaging.versionr   r   Úpip._internal.models.direct_urlr   r   r   Úpip._internal.utils.miscr   r   Úpip._vendor.packaging.utilsr   ÚobjectrE   Ú	getLoggerr!   r1   r   r&   rJ   r   r   r   r   Ú<module>   s$    (
u