o
    jF5                     @  sJ  d dl mZ d dlZd dlZd dl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mZ d dlmZ d dl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mZ d dl m!Z! d dl"m#Z# d dl$m%Z%m&Z& erd dl'm(Z( d dl)m*Z* G dd deZ+ee+ Z,e-e.Z/G dd deZ0d#ddZ1d$d!d"Z2dS )%    )annotationsN)	GeneratorIteratorSequence)Parser)Values)TYPE_CHECKINGcastcanonicalize_name)InvalidVersionVersion)
cmdoptions)IndexGroupCommand)SUCCESS)CommandError)BaseDistributionget_environment)SelectionPreferences)stdlib_pkgs)tabulatewrite_outputPackageFinder)
PipSessionc                   @  s"   e Zd ZU dZded< ded< dS )_DistWithLatestInfozGive the distribution object a couple of extra fields.

        These will be populated during ``get_outdated()``. This is dirty but
        makes the rest of the code much cleaner.
        r   latest_versionstrlatest_filetypeN)__name__
__module____qualname____doc____annotations__ r$   r$   \/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/pip/_internal/commands/list.pyr      s   
 r   c                      s   e Zd ZdZdZdZd)ddZejd* fddZ	d+ddZ
d,ddZd-ddZd-ddZd-ddZd.d d!Zd/d"d#Zd0d'd(Z  ZS )1ListCommandzt
    List installed packages, including editables.

    Packages are listed in a case-insensitive sorted order.
    Tz
      %prog [options]returnNonec                 C  s4  | j jdddddd | j jddddd	d | j jd
ddddd | j jdddddd | j jdddddd | j t  | j jddddddd | j jddddd | j jdd d!d"d | j jd#dd!d$d%d& | j t  ttj| j}ttj| j}| j	d'| | j	d'| | j	d'| j  d S )(Nz-oz
--outdated
store_trueFzList outdated packages)actiondefaulthelpz-uz
--uptodatezList uptodate packagesz-ez
--editablezList editable projects.z-lz--localzSIf in a virtualenv that has global access, do not list globally-installed packages.z--useruserz,Only output packages installed in user-site.)destr*   r+   r,   z--formatstorelist_formatcolumns)r1   freezejsonzSelect the output format among: columns (default), freeze, or json. The 'freeze' format cannot be used with the --outdated option.)r*   r.   r+   choicesr,   z--not-requirednot_requiredz>List packages that are not dependencies of installed packages.)r*   r.   r,   z--exclude-editablestore_falseinclude_editablez%Exclude editable package from output.z--include-editablez#Include editable package in output.T)r*   r.   r,   r+   r   )
cmd_opts
add_optionr   	list_pathlist_excludemake_option_groupindex_groupparserZpackage_selection_groupinsert_option_group)self
index_optsZselection_optsr$   r$   r%   add_options6   s   
zListCommand.add_optionsoptionsr   args	list[str]Iterator[None]c                 #  sR    |j s|jsd V  d S t || d V  W d    d S 1 s"w   Y  d S N)outdateduptodatesuperpip_version_check)r@   rC   rD   	__class__r$   r%   rK      s   "zListCommand.pip_version_checksessionr   r   c                 C  sB   ddl m} ddlm} |j||d}td|jd}|j||dS )zK
        Create a package finder appropriate to this list command.
        r   )LinkCollectorr   )rC   F)allow_yankedrelease_control)link_collectorselection_prefs)pip._internal.index.collectorrO   "pip._internal.index.package_finderr   creater   rQ   )r@   rC   rN   rO   r   rR   rS   r$   r$   r%   _build_package_finder   s   z!ListCommand._build_package_finderintc                 C  s   t | |jr|jrtd|jr|jdkrtdt | tt}|j	r2|
dd |j	D  dd t|jj|j|j|j|j|dD }|jrQ| ||}|jr[| ||}n	|jrd| ||}| || tS )	Nz5Options --outdated and --uptodate cannot be combined.r2   z?List format 'freeze' cannot be used with the --outdated option.c                 s  s    | ]}t |V  qd S rG   r
   ).0nr$   r$   r%   	<genexpr>       z"ListCommand.run.<locals>.<genexpr>c                 S  s   g | ]}t d |qS )r   )r	   )rY   dr$   r$   r%   
<listcomp>   s    z#ListCommand.run.<locals>.<listcomp>)
local_only	user_onlyeditables_onlyinclude_editablesskip)r   Zcheck_release_control_exclusiverH   rI   r   r0   check_list_path_optionsetr   excludesupdater   pathiter_installed_distributionslocalr-   editabler7   r5   get_not_requiredget_outdatedget_uptodateoutput_package_listingr   )r@   rC   rD   rc   packagesr$   r$   r%   run   s8   


zListCommand.runrp   _ProcessedDistsc                 C     dd |  ||D S )Nc                 S  s   g | ]
}|j |jkr|qS r$   r   versionrY   distr$   r$   r%   r^      
    z,ListCommand.get_outdated.<locals>.<listcomp>iter_packages_latest_infosr@   rp   rC   r$   r$   r%   rm         
zListCommand.get_outdatedc                 C  rs   )Nc                 S  s   g | ]
}|j |jkr|qS r$   rt   rv   r$   r$   r%   r^      rx   z,ListCommand.get_uptodate.<locals>.<listcomp>ry   r{   r$   r$   r%   rn      r|   zListCommand.get_uptodatec                   s$   dd |D  t  fdd|D S )Nc                 S  s(   h | ]}|  p	d D ]}t|jq
qS )r$   )iter_dependenciesr   name)rY   rw   depr$   r$   r%   	<setcomp>   s    
z/ListCommand.get_not_required.<locals>.<setcomp>c                   s   h | ]	}|j  vr|qS r$   canonical_name)rY   pkgZdep_keysr$   r%   r      s    )listr{   r$   r   r%   rl      s   	zListCommand.get_not_required*Generator[_DistWithLatestInfo, None, None]c                 #  sn     '}| d fdd}t||D ]	}|d ur$|V  qW d    d S 1 s0w   Y  d S )Nrw   r   r'   _DistWithLatestInfo | Nonec                   st     | j}| jrdd |D } j| jd}||}|d u r&d S |j}|jjr0d}nd}|| _|| _	| S )Nc                 S  s   g | ]}|j js|qS r$   )ru   is_prerelease)rY   	candidater$   r$   r%   r^      s    zOListCommand.iter_packages_latest_infos.<locals>.latest_info.<locals>.<listcomp>)project_namewheelsdist)
find_all_candidatesr   Zshould_exclude_prereleasemake_candidate_evaluatorsort_best_candidateru   linkis_wheelr   r   )rw   Zall_candidatesZ	evaluatorbest_candidateremote_versiontypfinderrC   r@   r$   r%   latest_info   s$   
z;ListCommand.iter_packages_latest_infos.<locals>.latest_info)rw   r   r'   r   )_build_sessionrW   map)r@   rp   rC   rN   r   rw   r$   r   r%   rz      s   "z&ListCommand.iter_packages_latest_infosc              	   C  s   t |dd d}|jdkr|rt||\}}| || d S |jdkrY|D ]1}z|j d|j }W n tyD   |j d|j }Y nw |jdkrRt	d	||j
 q%t	| q%d S |jd
krgt	t|| d S d S )Nc                 S  s   | j S rG   r   )rw   r$   r$   r%   <lambda>  s    z4ListCommand.output_package_listing.<locals>.<lambda>)keyr1   r2   z==z===   z%s (%s)r3   )sortedr0   format_for_columnsoutput_package_listing_columnsraw_nameru   r   raw_versionverboser   locationformat_for_json)r@   rp   rC   dataheaderrw   
req_stringr$   r$   r%   ro     s*   



	z"ListCommand.output_package_listingr   list[list[str]]r   c                 C  sb   t |dkr|d| t|\}}t |dkr&|dddd |D  |D ]}t| q(d S )Nr   r    c                 s  s    | ]}d | V  qdS )-Nr$   rY   xr$   r$   r%   r[   <  r\   z=ListCommand.output_package_listing_columns.<locals>.<genexpr>)leninsertr   joinr   )r@   r   r   Zpkg_stringssizesvalr$   r$   r%   r   1  s   
z*ListCommand.output_package_listing_columns)r'   r(   )rC   r   rD   rE   r'   rF   )rC   r   rN   r   r'   r   )rC   r   rD   rE   r'   rX   )rp   rr   rC   r   r'   rr   )rp   rr   rC   r   r'   r   )rp   rr   rC   r   r'   r(   )r   r   r   rE   r'   r(   )r   r    r!   r"   ignore_require_venvusagerB   
contextlibcontextmanagerrK   rW   rq   rm   rn   rl   rz   ro   r   __classcell__r$   r$   rL   r%   r&   +   s    
U


+
	
	

%r&   pkgsrr   rC   r   r'   !tuple[list[list[str]], list[str]]c                   sH  ddg}|j }|r|ddg dd	d
  fdd| D }t|}|r)|d tdd | D }|r9|d |jdkrC|d |jdkrM|d g }t| D ]L\}}	|	j|	jg}
|rm|
t|	j	 |
|	j
 |rx|
|| pvd |r|
|	jpd |jdkr|
|	jpd |jdkr|
|	j ||
 qS||fS )z_
    Convert the package data into something usable
    by output_package_listing_columns.
    Packager   ZLatestTyperw   r   r'   
str | Nonec                 S  s6   z|  d}W n
 ty   Y d S w t |dS )NWHEELBuild)	read_textFileNotFoundErrorr   parsestrget)rw   
wheel_filer$   r$   r%   wheel_build_tagO  s   z+format_for_columns.<locals>.wheel_build_tagc                   s   g | ]} |qS r$   r$   )rY   pr   r$   r%   r^   V  s    z&format_for_columns.<locals>.<listcomp>r   c                 s  s    | ]}|j V  qd S rG   )rk   r   r$   r$   r%   r[   [  s    z%format_for_columns.<locals>.<genexpr>zEditable project locationr   ZLocationZ	Installer N)rw   r   r'   r   )rH   extendanyappendr   	enumerater   r   r   r   r   editable_project_locationr   	installer)r   rC   r   Zrunning_outdatedZ
build_tagsZhas_build_tagsZhas_editablesr   iZprojrowr$   r   r%   r   B  s@   








r   rp   r   c              	   C  s   g }| D ]J}zt |j}W n ty   |j}Y nw |j|d}|jdkr1|jp)d|d< |j|d< |jr@t |j	|d< |j
|d< |j}|rI||d< || qt|S )	N)r~   ru   r   r   r   r   r   r   r   )r   ru   r   r   r   r   r   r   rH   r   r   r   r   r3   dumps)rp   rC   r   rw   ru   infor   r$   r$   r%   r   ~  s*   




r   )r   rr   rC   r   r'   r   )rp   rr   rC   r   r'   r   )3
__future__r   r   r3   loggingcollections.abcr   r   r   email.parserr   optparser   typingr   r	   Zpip._vendor.packaging.utilsr   Zpip._vendor.packaging.versionr   r   pip._internal.clir   Zpip._internal.cli.index_commandr   pip._internal.cli.status_codesr   pip._internal.exceptionsr   pip._internal.metadatar   r   $pip._internal.models.selection_prefsr   pip._internal.utils.compatr   pip._internal.utils.miscr   r   rU   r   pip._internal.network.sessionr   r   rr   	getLoggerr   loggerr&   r   r   r$   r$   r$   r%   <module>   s:    

  
<