Current File : //lib/python3.9/site-packages/pip/_internal/commands/__pycache__/show.cpython-39.pyc
a

[��f��@sddlZddlZddlZddlmZddlmZmZmZm	Z	m
Z
ddlmZddl
mZddlmZmZddlmZmZddlmZe�e�ZGd	d
�d
e�ZGdd�de�Ze
ed
fe
ed
fed�dd�Zeeeed�dd�Zeeeeed�dd�Z dS)�N)�Values)�Iterator�List�
NamedTuple�Optional�Tuple��canonicalize_name)�Command)�ERROR�SUCCESS)�BaseDistribution�get_default_environment)�write_outputc@s<eZdZdZdZdZdd�dd�Zeee	e
d�d	d
�ZdS)�ShowCommandzx
    Show information about one or more installed packages.

    The output is in RFC-compliant mail header format.
    z$
      %prog [options] <package> ...TN)�returncCs,|jjddddddd�|j�d|j�dS)	Nz-fz--files�files�
store_trueFz7Show the full list of installed files for each package.)�dest�action�default�helpr)Zcmd_optsZ
add_option�parserZinsert_option_group)�self�r�?/usr/lib/python3.9/site-packages/pip/_internal/commands/show.py�add_optionss�	zShowCommand.add_options)�options�argsrcCs8|st�d�tS|}t|�}t||j|jd�s4tStS)Nz.ERROR: Please provide a package name or names.)�
list_files�verbose)�logger�warningr�search_packages_info�
print_resultsrr r)rrr�query�resultsrrr�run(s

�zShowCommand.run)�__name__�
__module__�__qualname__�__doc__�usageZignore_require_venvrrr�str�intr'rrrrrs
rc@s�eZdZUeed<eed<eed<eeed<eeed<eed<eed<eeed<eed	<eed
<eed<eed<eed
<eeed<eeeed<dS)�_PackageInfo�name�version�location�requires�required_by�	installer�metadata_version�classifiers�summary�homepage�author�author_email�license�entry_pointsrN)r(r)r*r-�__annotations__rrrrrrr/6s
r/.)�entry�inforcCs\|rD|ddkrD|r |ddkr*|d7}n|dd�}|dd�}qttjg|�|�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�..���)rAN��r-�pathlib�Path)r?r@rrr�_convert_legacy_entryHs
rG)r%rc#s�t�}dd�|��D��dd�|D�}t�fdd�t||�D��}|rXt�dd�|��ttt	d��fd	d
�}tt
tt	d�dd
�}tt
tt	d�dd�}|D�],}z�|}Wnty�Yq�Yn0tdd�|��D�t	j
d�}	t||�t	j
d�}
z|�d�}|jdd�}Wnt�y.g}Yn0||��p@||�}
|
du�rRd}nt|
�}|j}t|jt	|j�|j�pxd|	|
|j|j�p�d|�dg�|�dd�|�dd�|�dd�|�dd�|�dd�||d�Vq�dS)z�
    Gather details from installed distributions. Print distribution name,
    version, location, and installed files. Installed files requires a
    pip generated 'installed-files.txt' in the distributions '.egg-info'
    directory.
    cSsi|]}|j|�qSr)�canonical_name��.0�distrrr�
<dictcomp>l�z(search_packages_info.<locals>.<dictcomp>cSsg|]}t|��qSrr)rJr0rrr�
<listcomp>mrMz(search_packages_info.<locals>.<listcomp>csg|]\}}|�vr|�qSrr)rJr0�pkg�Z	installedrrrNorMzPackage(s) not found: %s�, )�current_distrcs�fdd����D�S)Nc3s4|],}�jdd�|��D�vr|jdp*dVqdS)cSsh|]}t|j��qSr)r	r0)rJ�drrr�	<setcomp>yrMzRsearch_packages_info.<locals>._get_requiring_packages.<locals>.<genexpr>.<setcomp>�NameZUNKNOWNN)rH�iter_dependencies�metadatarI�rRrr�	<genexpr>us
��zHsearch_packages_info.<locals>._get_requiring_packages.<locals>.<genexpr>)�valuesrXrPrXr�_get_requiring_packagests
�z5search_packages_info.<locals>._get_requiring_packages)rKrcSs<z|�d�}Wnty"YdS0dd�t�|���D�S)NZRECORDcss |]}tt�|d��VqdS)rNrD)rJ�rowrrrrY�rMzCsearch_packages_info.<locals>._files_from_record.<locals>.<genexpr>)�	read_text�FileNotFoundError�csv�reader�
splitlines)rK�textrrr�_files_from_record|s
z0search_packages_info.<locals>._files_from_recordcs�z|�d�}Wnty"YdS0dd�|jdd�D�}|j}|j}|dusV|durZ|Szt�|��|��Wnty�|YS0�j	s�|S�fdd�|D�S)Nzinstalled-files.txtcss|]}|r|VqdS�Nr�rJ�prrrrY�rMzCsearch_packages_info.<locals>._files_from_legacy.<locals>.<genexpr>F��keependsc3s"|]}tt�|�j�j�VqdSrd)rGrErF�partsre�Zinfo_relrrrY�s)
r]r^rar2Zinfo_directoryrErF�relative_to�
ValueErrorri)rKrb�paths�rootr@rrjr�_files_from_legacy�s$

�z0search_packages_info.<locals>._files_from_legacycss|]}|jVqdSrd)r0)rJZreqrrrrY�rMz'search_packages_info.<locals>.<genexpr>)�keyzentry_points.txtFrgN�Z
ClassifierZSummaryz	Home-pageZAuthorzAuthor-emailZLicense)r0r1r2r3r4r5r6r7r8r9r:r;r<r=r)rZiter_distributions�sorted�zipr!r"�joinr
rr-r�KeyErrorrV�lowerr]rar^rWr/Zraw_namer1r2r5r6Zget_all�get)r%�envZquery_names�missingr[rcroZ
query_namerKr3r4Zentry_points_textr=Z
files_iterrrWrrPrr#csZ�












�r#)�
distributionsrr rc	CsPd}t|�D�]<\}}d}|dkr*td�td|j�td|j�td|j�td|j�td	|j�td
|j�td|j�td|j	�td
d�
|j��tdd�
|j��|�rtd|j
�td|j�td�|jD]}td|�q�td�|jD]}td|���q�|rtd�|jdu�r.td�q|jD]}td|����q4q|S)zC
    Print the information from installed distributions found.
    FTrz---zName: %szVersion: %szSummary: %sz
Home-page: %sz
Author: %szAuthor-email: %szLicense: %szLocation: %szRequires: %srQzRequired-by: %szMetadata-Version: %sz
Installer: %szClassifiers:z  %sz
Entry-points:zFiles:Nz+Cannot locate RECORD or installed-files.txt)�	enumeraterr0r1r8r9r:r;r<r2rtr3r4r6r5r7r=�stripr)	rzrr Zresults_printed�irKZ
classifierr?�linerrrr$�s>



r$)!r_ZloggingrEZoptparser�typingrrrrrZpip._vendor.packaging.utilsr	Zpip._internal.cli.base_commandr
Zpip._internal.cli.status_codesrrZpip._internal.metadatar
rZpip._internal.utils.miscrZ	getLoggerr(r!rr/r-rGr#�boolr$rrrr�<module>s&
%"`�