HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_internal/metadata/__pycache__/base.cpython-310.pyc
o

@%Ne�K�@s�ddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZm
Z
mZmZmZmZmZddlmZddlmZmZddlmZddlmZmZddlmZddlm Z m!Z!dd	l"m#Z#m$Z$m%Z%dd
l&m'Z'ddl(m)Z)m*Z*ddl+m,Z,m-Z-dd
l.m/Z/e
r�ddlm0Z0ne1Z0eeefZ2ee3ej4fZ5e�6e7�Z8Gdd�de0�Z9dee3dfdee3dfde3fdd�Z:Gdd�de0�Z;Gdd�d�Z<Gdd�de0�Z=Gdd�de=�Z>Gdd �d e=�Z?dS)!�N)
�IO�
TYPE_CHECKING�
Collection�	Container�Iterable�Iterator�List�Optional�Tuple�Union)�Requirement)�InvalidSpecifier�SpecifierSet)�NormalizedName)�
LegacyVersion�Version)�NoneMetadataError)�
site_packages�	user_site)�DIRECT_URL_METADATA_NAME�	DirectUrl�DirectUrlValidationError)�stdlib_pkgs)�egg_link_path_from_location�egg_link_path_from_sys_path)�is_local�normalize_path)�url_to_path)�Protocolc@sBeZdZedefdd��Zedefdd��Zedefdd��ZdS)	�BaseEntryPoint�returncC�t���N��NotImplementedError��self�r'�=/usr/lib/python3/dist-packages/pip/_internal/metadata/base.py�name6�zBaseEntryPoint.namecCr!r"r#r%r'r'r(�value:r*zBaseEntryPoint.valuecCr!r"r#r%r'r'r(�group>r*zBaseEntryPoint.groupN)�__name__�
__module__�__qualname__�property�strr)r+r,r'r'r'r(r5sr�entry.�infor cCsj|r)|ddkr)|r|ddkr|d7}n|dd�}|dd�}|r)|ddksttjg|�|�R��S)a�Convert a legacy installed-files.txt path into modern RECORD path.

    The legacy format stores paths relative to the info directory, while the
    modern format stores paths relative to the package root, e.g. the
    site-packages directory.

    :param entry: Path parts of the installed-files.txt entry.
    :param info: Path parts of the egg-info directory relative to package root.
    :returns: The converted entry.

    For best compatibility with symlinks, this does not use ``abspath()`` or
    ``Path.resolve()``, but tries to work with path parts:

    1. While ``entry`` starts with ``..``, remove the equal amounts of parts
       from ``info``; if ``info`` is empty, start appending ``..`` instead.
    2. Join the two directly.
    r�..���)r4N��r1�pathlib�Path)r2r3r'r'r(�_convert_installed_files_pathCs
�r:c@s|eZdZdefdd�Zdefdd�Zedeefdd��Zedeefdd	��Z	edeefd
d��Z
edeefdd
��Zedefdd��Z
edefdd��Zedefdd��Zedefdd��Zedefdd��Zedefdd��Zedefdd��Zedeefdd��Zedefdd��Zedefd d!��Zedefd"d#��Zedefd$d%��Zedefd&d'��Zd(edefd)d*�Zd(edee j!fd+d,�Z"d(edefd-d.�Z#de$e%fd/d0�Z&ede'j(j)fd1d2��Z*edeefd3d4��Z+edefd5d6��Z,ede-fd7d8��Z.dFd:e/ede$e0fd;d<�Z1de$efd=d>�Z2deeefd?d@�Z3deeefdAdB�Z4deeefdCdD�Z5dES)G�BaseDistributionr cCs|j�d|j�d|j�d�S)N� z (�))�raw_name�version�locationr%r'r'r(�__repr__bszBaseDistribution.__repr__cCs|j�d|j��S)Nr<)r>r?r%r'r'r(�__str__eszBaseDistribution.__str__cCr!)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.
        r#r%r'r'r(r@hszBaseDistribution.locationcCs8|j}|r|��rt|j�SdSt|j�}|r|jSdS)z�The project location for editable distributions.

        This is the directory where pyproject.toml or setup.py is located.
        None if the distribution is not installed in editable mode.
        N)�
direct_url�is_local_editabler�urlrr>r@)r&rC�
egg_link_pathr'r'r(�editable_project_locationvs
	
�z*BaseDistribution.editable_project_locationcCs2t|j�}|r
|}t|�S|jr|j}t|�SdS)a�The distribution's "installed" location.

        This should generally be a ``site-packages`` directory. This is
        usually ``dist.location``, except for legacy develop-installed packages,
        where ``dist.location`` is the source code location, and this is where
        the ``.egg-link`` file is.

        The returned location is normalized (in particular, with symlinks removed).
        N)rr>r@r)r&�egg_linkr@r'r'r(�installed_location�s
��z#BaseDistribution.installed_locationcCr!)a/Location of the .[egg|dist]-info directory or file.

        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.
        r#r%r'r'r(�
info_location�szBaseDistribution.info_locationcCs|j}|sdSt�|���S)aWhether this distribution is installed with legacy distutils format.

        A distribution installed with "raw" distutils not patched by setuptools
        uses one single file at ``info_location`` to store metadata. We need to
        treat this specially on uninstallation.
        F)rJr8r9�is_file�r&rJr'r'r(�installed_by_distutils�sz'BaseDistribution.installed_by_distutilscCs|j}|sdS|�d�S)z�Whether this distribution is installed as an egg.

        This usually indicates the distribution was installed by (older versions
        of) easy_install.
        Fz.egg)r@�endswith�r&r@r'r'r(�installed_as_egg�s
z!BaseDistribution.installed_as_eggcC�*|j}|sdS|�d�sdSt�|���S)a�Whether this distribution is installed with the ``.egg-info`` format.

        This usually indicates the distribution was installed with setuptools
        with an old pip version or with ``single-version-externally-managed``.

        Note that this ensure the metadata store is a directory. distutils can
        also installs an ``.egg-info``, but as a file, not a directory. This
        property is *False* for that case. Also see ``installed_by_distutils``.
        Fz	.egg-info�rJrNr8r9�is_dirrLr'r'r(�"installed_with_setuptools_egg_info�s
z3BaseDistribution.installed_with_setuptools_egg_infocCrQ)aaWhether this distribution is installed with the "modern format".

        This indicates a "modern" installation, e.g. storing metadata in the
        ``.dist-info`` directory. This applies to installations made by
        setuptools (but through pip, not directly), or anything using the
        standardized build backend interface (PEP 517).
        Fz
.dist-inforRrLr'r'r(�installed_with_dist_info�s	
z)BaseDistribution.installed_with_dist_infocCr!r"r#r%r'r'r(�canonical_name�r*zBaseDistribution.canonical_namecCr!r"r#r%r'r'r(r?�r*zBaseDistribution.versioncCs|j�dd�S)z�Convert a project name to its setuptools-compatible filename.

        This is a copy of ``pkg_resources.to_filename()`` for compatibility.
        �-�_)r>�replacer%r'r'r(�setuptools_filename�sz$BaseDistribution.setuptools_filenamec
Csrz|�t�}Wn
tyYdSwzt�|�WSttjtfy8}zt	�
dt|j|�WYd}~dSd}~ww)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.
        NzError parsing %s for %s: %s)�	read_textr�FileNotFoundErrorr�	from_json�UnicodeDecodeError�json�JSONDecodeErrorr�logger�warningrV)r&�content�er'r'r(rC�s*�����zBaseDistribution.direct_urlc
CsPz|�d�}Wn
tttfyYdSw|��D]}|��}|r%|SqdS)N�	INSTALLER�)r[�OSError�
ValueErrorr�
splitlines�strip)r&�installer_text�line�cleaned_liner'r'r(�	installers��zBaseDistribution.installercCs
t|j�Sr")�boolrGr%r'r'r(�editable!s
zBaseDistribution.editablecCs|jdurdSt|j�S)z|If distribution is installed in the current virtual environment.

        Always True if we're not in a virtualenv.
        NF)rIrr%r'r'r(�local%s

zBaseDistribution.localcC�&|jdus	tdurdS|j�tt��S�NF)rIr�
startswithrr%r'r'r(�in_usersite/�zBaseDistribution.in_usersitecCrrrs)rIrrtrr%r'r'r(�in_site_packages5rvz!BaseDistribution.in_site_packages�pathcCr!)z7Check whether an entry in the info directory is a file.r#�r&rxr'r'r(rK;r*zBaseDistribution.is_filecCr!)a$Iterate through a directory in the info directory.

        Each item yielded would be a path relative to the info directory.

        :raise FileNotFoundError: If ``name`` does not exist in the directory.
        :raise NotADirectoryError: If ``name`` does not point to a directory.
        r#ryr'r'r(�iterdir?szBaseDistribution.iterdircCr!)z�Read a file in the info directory.

        :raise FileNotFoundError: If ``name`` does not exist in the directory.
        :raise NoneMetadataError: If ``name`` exists in the info directory, but
            cannot be read.
        r#ryr'r'r(r[I�zBaseDistribution.read_textcCr!r"r#r%r'r'r(�iter_entry_pointsR�z"BaseDistribution.iter_entry_pointscCr!)aMetadata of distribution parsed from e.g. METADATA or PKG-INFO.

        This should return an empty message if the metadata file is unavailable.

        :raises NoneMetadataError: If the metadata file is available, but does
            not contain valid metadata.
        r#r%r'r'r(�metadataUs	zBaseDistribution.metadatacCs|j�d�S)zDValue of "Metadata-Version:" in distribution metadata, if available.zMetadata-Version)r~�getr%r'r'r(�metadata_version`sz!BaseDistribution.metadata_versioncCs|j�d|j�S)z*Value of "Name:" in distribution metadata.�Name)r~rrVr%r'r'r(r>eszBaseDistribution.raw_namec
Csl|j�d�}|dur
t�Sz	tt|��}W|Sty5}zd}t�||j|�t�WYd}~Sd}~ww)z�Value of "Requires-Python:" in distribution metadata.

        If the key does not exist or contains an invalid value, an empty
        SpecifierSet should be returned.
        zRequires-PythonNz-Package %r has an invalid Requires-Python: %s)r~rrr1r
rarbr>)r&r+�specrd�messager'r'r(�requires_pythonls���z BaseDistribution.requires_pythonr'�extrascCr!)z�Dependencies of this distribution.

        For modern .dist-info distributions, this is the collection of
        "Requires-Dist:" entries in distribution metadata.
        r#)r&r�r'r'r(�iter_dependencies�z"BaseDistribution.iter_dependenciescCr!)z�Extras provided by this distribution.

        For modern .dist-info distributions, this is the collection of
        "Provides-Extra:" entries in distribution metadata.
        r#r%r'r'r(�iter_provided_extras�r�z%BaseDistribution.iter_provided_extrascCs<z|�d�}Wn
tyYdSwdd�t�|���D�S)N�RECORDcss"�|]}tt�|d��VqdS)rNr7)�.0�rowr'r'r(�	<genexpr>�s� zFBaseDistribution._iter_declared_entries_from_record.<locals>.<genexpr>)r[r\�csv�readerri)r&�textr'r'r(�"_iter_declared_entries_from_record�s�z3BaseDistribution._iter_declared_entries_from_recordcs�z|�d�}Wn
tyYdSwdd�|jdd�D�}|j}|j}|dus+|dur-|Sz
t�|��|��WntyB|YSw�j	sH|S�fdd�|D�S)Nzinstalled-files.txtcss�|]}|r|VqdSr"r'�r��pr'r'r(r��s�zFBaseDistribution._iter_declared_entries_from_legacy.<locals>.<genexpr>F)�keependsc3s$�|]
}tt�|�j�j�VqdSr")r:r8r9�partsr���info_relr'r(r��s
��
�)
r[r\rir@rJr8r9�relative_torhr�)r&r��paths�rootr3r'r�r(�"_iter_declared_entries_from_legacy�s(��
�z3BaseDistribution._iter_declared_entries_from_legacycCs|��p|��S)a�Iterate through file entires declared in this distribution.

        For modern .dist-info distributions, this is the files listed in the
        ``RECORD`` metadata file. For legacy setuptools distributions, this
        comes from ``installed-files.txt``, with entries normalized to be
        compatible with the format used by ``RECORD``.

        :return: An iterator for listed entries, or None if the distribution
            contains neither ``RECORD`` nor ``installed-files.txt``.
        )r�r�r%r'r'r(�iter_declared_entries�s�z&BaseDistribution.iter_declared_entriesN)r')6r-r.r/r1rArBr0r	r@rGrIrJrorMrPrTrUrrV�DistributionVersionr?rZrrCrnrprqrurw�InfoPathrKrr8�
PurePosixPathrzr[rrr|�emailr��Messager~r�r>rr�rrr�r�r�r�r�r'r'r'r(r;asl
	
	
r;c@s�eZdZdZeddd��Zedeeeddfdd��Z	deded	fd
d�Z
ded	fdd
�Zded	fdd�Z
dedddfdedeededededeefdd�ZdS)�BaseEnvironmentz6An environment containing distributions to introspect.r cCr!r"r#)�clsr'r'r(�default�r*zBaseEnvironment.defaultr�cCr!r"r#)r�r�r'r'r(�
from_paths�r*zBaseEnvironment.from_pathsr)r;cCr!)z�Given a requirement name, return the installed distributions.

        The name may not be normalized. The implementation must canonicalize
        it for lookup.
        r#)r&r)r'r'r(�get_distribution�r�z BaseEnvironment.get_distributioncCr!)aIterate 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.
        r#r%r'r'r(�_iter_distributions�r{z#BaseEnvironment._iter_distributionsccsF�|��D]}tjd|jtjd�}|st�d|j|j�q|VqdS)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)r��re�matchrV�
IGNORECASErarbr@)r&�dist�project_name_validr'r'r(�iter_distributions�s ����z"BaseEnvironment.iter_distributionsTF�
local_only�skip�include_editables�editables_only�	user_onlycsb|��}|r
dd�|D�}|sdd�|D�}|rdd�|D�}|r(dd�|D�}�fdd�|D�S)aReturn 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.
        cs��|]}|jr|VqdSr")rq�r��dr'r'r(r���z?BaseEnvironment.iter_installed_distributions.<locals>.<genexpr>css�|]}|js|VqdSr"�rpr�r'r'r(r�r�csr�r"r�r�r'r'r(r�r�csr�r")rur�r'r'r(r�	r�c3s�|]
}|j�vr|VqdSr")rVr��r�r'r(r�
s�)r�)r&r�r�r�r�r��itr'r�r(�iter_installed_distributions�sz,BaseEnvironment.iter_installed_distributionsN)r r�)r-r.r/�__doc__�classmethodr�r	rr1r�r�rr�r�rrorr;r�r'r'r'r(r��s6	�������r�c@s&eZdZUeed<dejfdd�ZdS)�Wheelr@r cCr!r"r#r%r'r'r(�
as_zipfiler}zWheel.as_zipfileN)r-r.r/r1�__annotations__�zipfile�ZipFiler�r'r'r'r(r�
s
r�c@s.eZdZdeddfdd�Zdejfdd�ZdS)�FilesystemWheelr@r NcCs
||_dSr")r@rOr'r'r(�__init__s
zFilesystemWheel.__init__cC�tj|jdd�S�NT)�
allowZip64)r�r�r@r%r'r'r(r��zFilesystemWheel.as_zipfile)r-r.r/r1r�r�r�r�r'r'r'r(r�sr�c@s6eZdZdedeeddfdd�Zdejfdd�Z	dS)	�MemoryWheelr@�streamr NcCs||_||_dSr")r@r�)r&r@r�r'r'r(r�s
zMemoryWheel.__init__cCr�r�)r�r�r�r%r'r'r(r�!r�zMemoryWheel.as_zipfile)
r-r.r/r1r�bytesr�r�r�r�r'r'r'r(r�sr�)@r��
email.messager�r_�loggingr8r�r��typingrrrrrrrr	r
r�"pip._vendor.packaging.requirementsr� pip._vendor.packaging.specifiersr
r�pip._vendor.packaging.utilsr�pip._vendor.packaging.versionrr�pip._internal.exceptionsr�pip._internal.locationsrr�pip._internal.models.direct_urlrrr�pip._internal.utils.compatr�pip._internal.utils.egg_linkrr�pip._internal.utils.miscrr�pip._internal.utils.urlsrr�objectr�r1r�r��	getLoggerr-rarr:r;r�r�r�r�r'r'r'r(�<module>sP0


�
�
�^P