o
    ii                     @   s   d dl 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 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)default_environment)
print_json)__version__)
cmdoptions)Command)SUCCESS)BaseDistributionget_environment)stdlib_pkgs)path_to_urlc                   @   sV   e Zd ZdZdZdZdddZded	ee	 de
fd
dZdedee	ef fddZdS )InspectCommandzZ
    Inspect the content of a Python environment and produce a report in JSON format.
    Tz
      %prog [options]returnNc                 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   )Zcmd_optsZ
add_optionr   Z	list_pathparserZinsert_option_groupself r   >lib/python3.10/site-packages/pip/_internal/commands/inspect.pyadd_options   s   	zInspectCommand.add_optionsoptionsargsc                    sT   t | t|jj|j|jttd}dt	 fdd|D t
 d}t|d tS )N)Z
local_onlyZ	user_onlyskip1c                    s   g | ]}  |qS r   )_dist_to_dict).0distr   r   r   
<listcomp>:   s    z&InspectCommand.run.<locals>.<listcomp>)versionZpip_versionZ	installedZenvironment)data)r   Zcheck_list_path_optionr   pathZiter_installed_distributionslocalr   setr   r   r   r   r	   )r   r   r   Zdistsoutputr   r   r   run0   s   


zInspectCommand.runr"   c                 C   sv   |j |jd}|j}|d ur| |d< n|j}|d ur't|ddid|d< |j}|jr1||d< |jr9|j|d< |S )N)ZmetadataZmetadata_location
direct_urlZeditableT)urlZdir_info	installer	requested)	Zmetadata_dictZinfo_locationr+   Zto_dicteditable_project_locationr   r-   Zinstalled_with_dist_infor.   )r   r"   resr+   r/   r-   r   r   r   r    A   s$   

zInspectCommand._dist_to_dict)r   N)__name__
__module____qualname____doc__Zignore_require_venvusager   r   liststrintr*   r
   dictr   r    r   r   r   r   r      s    
r   )ZloggingZoptparser   typingr   Zpip._vendor.packaging.markersr   Zpip._vendor.richr   Zpipr   Zpip._internal.clir   Zpip._internal.cli.base_commandr   Zpip._internal.cli.status_codesr	   Zpip._internal.metadatar
   r   Zpip._internal.utils.compatr   Zpip._internal.utils.urlsr   Z	getLoggerr1   loggerr   r   r   r   r   <module>   s    
