a
    |Ä#dt  ã                   @   s¶   d dl Z d dlmZ d dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZ d dlmZ d dlmZ e  e¡ZG dd„ deƒZdS )é    N)ÚValues)ÚAnyÚDictÚList)Údefault_environment)Ú
print_json)Ú__version__)Ú
cmdoptions)ÚCommand)ÚSUCCESS)ÚBaseDistributionÚget_environment)Ústdlib_pkgs)Úpath_to_urlc                   @   sT   e Zd ZdZdZdZddœdd„Zeee	 e
dœd	d
„Zeee	ef dœdd„ZdS )ÚInspectCommandzZ
    Inspect the content of a Python environment and produce a report in JSON format.
    Tz
      %prog [options]N)Úreturnc                 C   sN   | j jddddd� | j jdddddd	� | j  t ¡ ¡ | j d
| j ¡ d S )Nz--localÚ
store_trueFzSIf in a virtualenv that has global access, do not list globally-installed packages.)ÚactionÚdefaultÚhelpz--userÚuserz,Only output packages installed in user-site.)Údestr   r   r   r   )Úcmd_optsÚ
add_optionr	   Ú	list_pathÚparserÚinsert_option_group©Úself© r   úU/var/www/html/gsl.tools/lib/python3.9/site-packages/pip/_internal/commands/inspect.pyÚadd_options   s    û	ûzInspectCommand.add_options)ÚoptionsÚargsr   c                    sT   t  |¡ t|jƒj|j|jttƒd�}dt	‡ fdd„|D ƒt
ƒ dœ}t|d� tS )N)Ú
local_onlyÚ	user_onlyÚskipÚ1c                    s   g | ]}ˆ   |¡‘qS r   )Ú_dist_to_dict)Ú.0Údistr   r   r    Ú
<listcomp>:   ó    z&InspectCommand.run.<locals>.<listcomp>)ÚversionÚpip_versionÚ	installedÚenvironment)Údata)r	   Úcheck_list_path_optionr   ÚpathÚiter_installed_distributionsÚlocalr   Úsetr   r   r   r   r   )r   r"   r#   ÚdistsÚoutputr   r   r    Úrun0   s    

ýü
zInspectCommand.run)r*   r   c                 C   sv   |j |jdœ}|j}|d ur*| ¡ |d< n$|j}|d urNt|ƒddidœ|d< |j}|jrb||d< |jrr|j|d< |S )N)ÚmetadataZmetadata_locationÚ
direct_urlÚeditableT)ÚurlÚdir_infoÚ	installerÚ	requested)	Úmetadata_dictÚinfo_locationr;   Úto_dictÚeditable_project_locationr   r?   Úinstalled_with_dist_infor@   )r   r*   Úresr;   rD   r?   r   r   r    r(   A   s$    þÿþ

zInspectCommand._dist_to_dict)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úignore_require_venvÚusager!   r   r   ÚstrÚintr9   r   r   r   r(   r   r   r   r    r      s   r   )ÚloggingÚoptparser   Útypingr   r   r   Zpip._vendor.packaging.markersr   Úpip._vendor.richr   Úpipr   Úpip._internal.clir	   Úpip._internal.cli.req_commandr
   Úpip._internal.cli.status_codesr   Úpip._internal.metadatar   r   Úpip._internal.utils.compatr   Úpip._internal.utils.urlsr   Ú	getLoggerrG   Úloggerr   r   r   r   r    Ú<module>   s   
