o
    a+)h70                  	   @   s^  d dl Z d dlZd dlmZ d dlmZmZmZmZ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 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$m%Z% erd dl&m'Z' G dd deZ(e	e( Z)e*e+Z,G dd deZ-dddede
eee.  ee. f fddZ/dddede.fddZ0dS )    N)Values)TYPE_CHECKING	GeneratorListOptionalSequenceTuplecastcanonicalize_name)
cmdoptions)IndexGroupCommand)SUCCESS)CommandError)LinkCollector)PackageFinder)BaseDistributionget_environment)SelectionPreferences)
PipSession)stdlib_pkgs)tabulatewrite_output)DistributionVersionc                   @   s"   e Zd ZU dZeed< e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.
        latest_versionlatest_filetypeN)__name__
__module____qualname____doc__r   __annotations__str r#   r#   ZC:\Users\User\Downloads\Proyecto_IoT\venv\Lib\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ded	ede	fd
dZ
dedee defddZdddeddfddZdddeddfddZdddeddfddZdddeded fddZdddeddfddZdeee  dee ddfddZdS )!ListCommandzt
    List installed packages, including editables.

    Packages are listed in a case-insensitive sorted order.
    Tz
      %prog [options]returnNc                 C   s*  | 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 | 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}| 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--prezYInclude pre-release and development versions. By default, pip only finds stable versions.z--formatstorelist_formatcolumns)r/   freezejsonzBSelect the output format among: columns (default), freeze, or json)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 from output.T)r(   r,   r*   r)   r   )	cmd_opts
add_optionr   	list_pathlist_excludemake_option_groupindex_groupparserinsert_option_group)self
index_optsr#   r#   r$   add_options2   s   

	zListCommand.add_optionsoptionssessionc                 C   s*   t j||d}td|jd}tj||dS )zK
        Create a package finder appropriate to this list command.
        )rA   F)allow_yankedallow_all_prereleases)link_collectorselection_prefs)r   creater   prer   )r>   rA   rB   rE   rF   r#   r#   r$   _build_package_finder   s   z!ListCommand._build_package_finderargsc                 C   s   |j r
|jr
td|j r|jdkrtdt| tt}|jr-|	dd |jD  dd t
|jj|j|j|j|j|dD }|jrL| ||}|j rV| ||}n	|jr_| ||}| || tS )	Nz5Options --outdated and --uptodate cannot be combined.r0   z@List format 'freeze' can not be used with the --outdated option.c                 s   s    | ]}t |V  qd S Nr
   ).0nr#   r#   r$   	<genexpr>   s    z"ListCommand.run.<locals>.<genexpr>c                 S   s   g | ]}t d |qS )r   )r	   )rL   dr#   r#   r$   
<listcomp>   s    z#ListCommand.run.<locals>.<listcomp>)
local_only	user_onlyeditables_onlyinclude_editablesskip)outdatedZuptodater   r.   r   check_list_path_optionsetr   excludesupdater   pathiter_installed_distributionslocalr+   editabler5   r3   get_not_requiredget_outdatedget_uptodateoutput_package_listingr   )r>   rA   rJ   rU   packagesr#   r#   r$   run   s6   

zListCommand.runrc   _ProcessedDistsc                 C      dd |  ||D S )Nc                 S   s   g | ]
}|j |jkr|qS r#   r   versionrL   distr#   r#   r$   rP      
    z,ListCommand.get_outdated.<locals>.<listcomp>iter_packages_latest_infosr>   rc   rA   r#   r#   r$   r`         
zListCommand.get_outdatedc                 C   rf   )Nc                 S   s   g | ]
}|j |jkr|qS r#   rg   ri   r#   r#   r$   rP      rk   z,ListCommand.get_uptodate.<locals>.<listcomp>rl   rn   r#   r#   r$   ra      ro   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)rL   rj   depr#   r#   r$   	<setcomp>   s    
z/ListCommand.get_not_required.<locals>.<setcomp>c                    s   h | ]	}|j  vr|qS r#   canonical_name)rL   pkgZdep_keysr#   r$   rs      s    )listrn   r#   rw   r$   r_      s   	zListCommand.get_not_required)r   NNc                 #   sx    |  ,}| | dddtd f fdd}t||D ]	}|d ur)|V  q W d    d S 1 s5w   Y  d S )Nrj   r   r&   c                    sl     | j}jsdd |D } j| jd}||}|d u r"d S |j}|jjr,d}nd}|| _|| _	| S )Nc                 S   s   g | ]}|j js|qS r#   )rh   is_prerelease)rL   	candidater#   r#   r$   rP      s    zOListCommand.iter_packages_latest_infos.<locals>.latest_info.<locals>.<listcomp>)project_namewheelsdist)
find_all_candidatesru   rH   make_candidate_evaluatorsort_best_candidaterh   linkis_wheelr   r   )rj   Zall_candidatesZ	evaluatorbest_candidateremote_versiontypfinderrA   r#   r$   latest_info   s$   
z;ListCommand.iter_packages_latest_infos.<locals>.latest_info)_build_sessionrI   r   map)r>   rc   rA   rB   r   rj   r#   r   r$   rm      s   "z&ListCommand.iter_packages_latest_infosc                 C   s   t |dd d}|jdkr|rt||\}}| || d S |jdkrB|D ]}|jdkr7td|j|j|j q%td|j|j q%d S |jd	krPtt	|| d S d S )
Nc                 S   s   | j S rK   rt   )rj   r#   r#   r$   <lambda>  s    z4ListCommand.output_package_listing.<locals>.<lambda>)keyr/   r0      z%s==%s (%s)z%s==%sr1   )
sortedr.   format_for_columnsoutput_package_listing_columnsverboser   raw_namerh   locationformat_for_json)r>   rc   rA   dataheaderrj   r#   r#   r$   rb   	  s$   


z"ListCommand.output_package_listingr   r   c                 C   sb   t |dkr|d| t|\}}t |dkr&|ddtdd | |D ]}t| q(d S )Nr   r    c                 S   s   d|  S )N-r#   )xr#   r#   r$   r   )  s    z<ListCommand.output_package_listing_columns.<locals>.<lambda>)leninsertr   joinr   r   )r>   r   r   Zpkg_stringssizesvalr#   r#   r$   r     s   
z*ListCommand.output_package_listing_columns)r&   N)r   r   r   r    ignore_require_venvusager@   r   r   r   rI   r   r"   intrd   r`   ra   r_   r   rm   rb   r   r#   r#   r#   r$   r%   '   sn    
U
)
	
	

&

r%   pkgsre   rA   r&   c                 C   s   ddg}|j }|r|ddg tdd | D }|r |d |jdkr*|d	 |jdkr4|d
 g }| D ]A}|jt|jg}|rR|t|j ||j	 |r\||j
pZd |jdkri||jpgd |jdkrt||j || q8||fS )z_
    Convert the package data into something usable
    by output_package_listing_columns.
    PackageVersionZLatestTypec                 s   s    | ]}|j V  qd S rK   )r^   )rL   r   r#   r#   r$   rN   <  s    z%format_for_columns.<locals>.<genexpr>zEditable project locationr   ZLocationZ	Installer )rV   extendanyappendr   r   r"   rh   r   r   editable_project_locationr   	installer)r   rA   r   Zrunning_outdatedZhas_editablesr   Zprojrowr#   r#   r$   r   /  s2   






r   rc   c                 C   s   g }| D ]9}|j t|jd}|jdkr |jpd|d< |j|d< |jr/t|j|d< |j|d< |j	}|r8||d< |
| qt|S )	N)rq   rh   r   r   r   r   r   r   r   )r   r"   rh   r   r   r   rV   r   r   r   r   r1   dumps)rc   rA   r   rj   infor   r#   r#   r$   r   \  s    



r   )1r1   loggingoptparser   typingr   r   r   r   r   r   r	   Zpip._vendor.packaging.utilsr   Zpip._internal.clir   pip._internal.cli.req_commandr   pip._internal.cli.status_codesr   pip._internal.exceptionsr   pip._internal.index.collectorr   "pip._internal.index.package_finderr   pip._internal.metadatar   r   $pip._internal.models.selection_prefsr   pip._internal.network.sessionr   pip._internal.utils.compatr   pip._internal.utils.miscr   r   Zpip._internal.metadata.baser   r   re   	getLoggerr   loggerr%   r"   r   r   r#   r#   r#   r$   <module>   s@    $

  

-