a
    |Ä#d70  ã                   @   sX  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�rd dl&m'Z' G dd„ deƒZ(e	e( Z)e *e+¡Z,G dd„ deƒZ-dee
eee.  ee. f dœdd„Z/dee.dœ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 )Ú_DistWithLatestInfoz¾Give 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#   úR/var/www/html/gsl.tools/lib/python3.9/site-packages/pip/_internal/commands/list.pyr      s   
r   c                   @   sÊ   e Zd ZdZdZdZddœdd„Zeee	dœd	d
„Z
eee edœdd„Zdeddœdd„Zdeddœdd„Zdeddœdd„Zdeed dœdd„Zdeddœdd„Zeee  ee ddœdd„ZdS )ÚListCommandzt
    List installed packages, including editables.

    Packages are listed in a case-insensitive sorted order.
    Tz
      %prog [options]N)Úreturnc                 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Úsessionr&   c                 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)rA   Úargsr&   c                 C   sÎ   |j r|jrtdƒ‚|j r,|jdkr,tdƒ‚t |¡ ttƒ}|jrZ| 	dd„ |jD ƒ¡ dd„ t
|jƒj|j|j|j|j|d�D ƒ}|jr˜|  ||¡}|j r¬|  ||¡}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>§   ó    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   rV   Úpackagesr#   r#   r$   Úrunš   s6    ÿ

ûþzListCommand.runÚ_ProcessedDists©rd   rA   r&   c                 C   s   dd„ |   ||¡D ƒS )Nc                 S   s   g | ]}|j |jkr|‘qS r#   ©r   Úversion©rL   Údistr#   r#   r$   rQ   Æ   s   þz,ListCommand.get_outdated.<locals>.<listcomp>©Úiter_packages_latest_infos©r>   rd   rA   r#   r#   r$   ra   Ã   s    
þzListCommand.get_outdatedc                 C   s   dd„ |   ||¡D ƒS )Nc                 S   s   g | ]}|j |jkr|‘qS r#   rh   rj   r#   r#   r$   rQ   Ï   s   þz,ListCommand.get_uptodate.<locals>.<listcomp>rl   rn   r#   r#   r$   rb   Ì   s    
þ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   rk   Ú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$   rr   á   rO   )Úlistrn   r#   rv   r$   r`   Õ   s    þ	zListCommand.get_not_required)r   NNc                 #   sr   |   ˆ¡�T}|  ˆ|¡‰ dtd dœ‡ ‡fdd„}t||ƒD ]}|d ur<|V  q<W d   ƒ n1 sd0    Y  d S )Nr   )rk   r&   c                    sl   ˆ   | j¡}ˆjs dd„ |D ƒ}ˆ j| jd�}| |¡}|d u rDd S |j}|jjrXd}nd}|| _|| _	| S )Nc                 S   s   g | ]}|j js|‘qS r#   )ri   Úis_prerelease)rL   Ú	candidater#   r#   r$   rQ   ï   s   þzOListCommand.iter_packages_latest_infos.<locals>.latest_info.<locals>.<listcomp>)Úproject_nameÚwheelÚsdist)
Úfind_all_candidatesrt   rH   Úmake_candidate_evaluatorÚsort_best_candidateri   ÚlinkÚis_wheelr   r   )rk   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>   rd   rA   rB   r‡   rk   r#   r…   r$   rm   ã   s    þz&ListCommand.iter_packages_latest_infosc                 C   sœ   t |dd„ d�}|jdkr:|r:t||ƒ\}}|  ||¡ n^|jdkr€|D ]4}|jdkrltd|j|j|jƒ qHtd|j|jƒ qHn|jd	kr˜tt	||ƒƒ d S )
Nc                 S   s   | j S rK   rs   )rk   r#   r#   r$   Ú<lambda>  rO   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_nameri   ÚlocationÚformat_for_json)r>   rd   rA   ÚdataÚheaderrk   r#   r#   r$   rc   	  s     þ

ÿ
z"ListCommand.output_package_listing)r”   r•   r&   c                 C   sb   t |ƒdkr| d|¡ t|ƒ\}}t |ƒdkrL| dd tdd„ |ƒ¡¡ |D ]}t|ƒ qPd S )Nr   rŒ   ú c                 S   s   d|  S )Nú-r#   )Úxr#   r#   r$   rŠ   )  rO   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   r   r   r    Úignore_require_venvÚusager@   r   r   r   rI   r   r"   Úintre   ra   rb   r`   r   rm   rc   r�   r#   r#   r#   r$   r%   '   s4   Vþ*þ
þ
þþ'þþr%   rf   )ÚpkgsrA   r&   c                 C   sü   ddg}|j }|r | ddg¡ tdd„ | D ƒƒ}|r@| d¡ |jdkrT| d	¡ |jdkrh| d
¡ g }| D ]‚}|jt|jƒg}|r¤| t|jƒ¡ | |j	¡ |r¸| |j
p´d¡ |jdkrÒ| |jpÎd¡ |jdkrè| |j¡ | |¡ qp||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   <  rO   z%format_for_columns.<locals>.<genexpr>zEditable project locationrŒ   ZLocationZ	InstallerÚ )rW   ÚextendÚanyÚappendr�   r‘   r"   ri   r   r   Úeditable_project_locationr’   Ú	installer)r¡   rA   r•   Zrunning_outdatedZhas_editablesr”   ZprojÚrowr#   r#   r$   rŽ   /  s2    






rŽ   rg   c                 C   s†   g }| D ]r}|j t|jƒdœ}|jdkr@|jp0d|d< |j|d< |jr^t|jƒ|d< |j|d< |j	}|rp||d< | 
|¡ qt |¡S )	N)rp   ri   rŒ   r¥   r’   rª   r   r   r©   )r‘   r"   ri   r�   r’   rª   rW   r   r   r©   r¨   r1   Údumps)rd   rA   r”   rk   Úinfor©   r#   r#   r$   r“   \  s     þ


r“   )1r1   ÚloggingÚoptparser   Útypingr   r   r   r   r   r   r	   Zpip._vendor.packaging.utilsr   Ú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   rf   Ú	getLoggerr   Úloggerr%   r"   rŽ   r“   r#   r#   r#   r$   Ú<module>   s6   $

  þ-