
    kg0              	          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e      Z(e	e(   Z) ejT                  e+      Z, G d de      Z-dddede
eee.      ee.   f   fdZ/dddede.fdZ0y)    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                   &    e Zd ZU dZeed<   eed<   y)_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     O/var/www/kongo/venv/lib/python3.12/site-packages/pip/_internal/commands/list.pyr   r      s    	 ,+r&   r   c                       e Zd ZdZdZdZddZdedede	fd	Z
ded
ee   defdZdddeddfdZdddeddfdZdddeddfdZdddeded   fdZdddeddfdZdeee      dee   ddfdZy)ListCommandzt
    List installed packages, including editables.

    Packages are listed in a case-insensitive sorted order.
    Tz
      %prog [options]returnNc                    | j                   j                  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       | j                   j                  ddddd       | j                   j                  t        j                                | j                   j                  dddd       | j                   j                  dddddd       | j                   j                  dddd        | j                   j                  d!d"d#d$        | j                   j                  d%dd#d&d'(       | j                   j                  t        j                                t        j
                  t        j                  | j                        }| j                  j                  d)|       | j                  j                  d)| j                          y )*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)r4   freezejsonzSelect the output format among: columns (default), freeze, or json. The 'freeze' format cannot be used with the --outdated option.)r-   r1   r.   choicesr/   z--not-requirednot_requiredz>List packages that are not dependencies of installed packages.)r-   r1   r/   z--exclude-editablestore_falseinclude_editablez%Exclude editable package from output.z--include-editablez%Include editable package from output.T)r-   r1   r/   r.   r   )	cmd_opts
add_optionr   	list_pathlist_excludemake_option_groupindex_groupparserinsert_option_group)self
index_optss     r'   add_optionszListCommand.add_options2   s     ) 	! 	
 	  ) 	! 	
 	  * 	! 	
 	  / 	! 		
 	  ? 	! 	
 	  !5!5!78  2 	! 	
 	  1Q 	! 
	
 	  Q	 	! 	
 	    #8	 	! 	
 	   #8 	! 	
 	  !8!8!:;11*2H2H$++V
'':6''4==9r&   optionssessionc                     t        j                  ||      }t        d|j                        }t	        j                  ||      S )zK
        Create a package finder appropriate to this list command.
        )rF   F)allow_yankedallow_all_prereleases)link_collectorselection_prefs)r   creater   prer   )rC   rF   rG   rK   rL   s        r'   _build_package_finderz!ListCommand._build_package_finder   sG     '--gwG /")++

 ##)+
 	
r&   argsc                    |j                   r|j                  rt        d      |j                   r|j                  dk(  rt        d      t	        j
                  |       t        t              }|j                  r"|j                  d |j                  D               t        |j                        j                  |j                  |j                  |j                  |j                   |      D cg c]  }t#        d|       }}|j$                  r| j'                  ||      }|j                   r| j)                  ||      }n|j                  r| j+                  ||      }| j-                  ||       t.        S c c}w )Nz5Options --outdated and --uptodate cannot be combined.r5   z?List format 'freeze' cannot be used with the --outdated option.c              3   2   K   | ]  }t        |        y wNr   ).0ns     r'   	<genexpr>z"ListCommand.run.<locals>.<genexpr>   s     G)!,Gs   )
local_only	user_onlyeditables_onlyinclude_editablesskipr   )outdateduptodater   r3   r   check_list_path_optionsetr   excludesupdater   pathiter_installed_distributionslocalr0   editabler:   r
   r8   get_not_requiredget_outdatedget_uptodateoutput_package_listingr   )rC   rF   rP   r[   dpackagess         r'   runzListCommand.run   sQ    0 0VWW 3 3x ?Q  	))'2;KKGg6F6FGG %W\\2OO"==!,,&//")":": P 	'
 &*	'
 	'
 ,,Xw?H((7;H((7;H##Hg61	'
s   /E7rk   _ProcessedDistsc                 ~    | j                  ||      D cg c]  }|j                  |j                  kD  r| c}S c c}w rS   iter_packages_latest_infosr   versionrC   rk   rF   dists       r'   rg   zListCommand.get_outdated   sC    
 77'J
""T\\1 
 	
 
   ":c                 ~    | j                  ||      D cg c]  }|j                  |j                  k(  r| c}S c c}w rS   ro   rr   s       r'   rh   zListCommand.get_uptodate   sC    
 77'J
""dll2 
 	
 
rt   c                     |D ch c]0  }|j                         xs dD ]  }t        |j                         2 }}}t        |D ch c]  }|j                  |vs| c}      S c c}}w c c}w )Nr%   )iter_dependenciesr   namelistcanonical_name)rC   rk   rF   rs   depdep_keyspkgs          r'   rf   zListCommand.get_not_required   s}    
 !
..06B
  chh'
'
 
 HSS0B0B(0RSSTT
 Ts   5A&A,A,)r   NNc              #      K   | j                        5 }| j                  |      dddt        d   ffd}t        ||      D ]	  }||  	 d d d        y # 1 sw Y   y xY ww)Nrs   r   r*   c                 t   j                  | j                        }j                  s%|D cg c]  }|j                  j                  s| }}j                  | j                        }|j                  |      }|y |j                  }|j                  j                  rd}nd}|| _	        || _
        | S c c}w )N)project_namewheelsdist)find_all_candidatesrz   rN   rq   is_prereleasemake_candidate_evaluatorsort_best_candidatelinkis_wheelr   r   )	rs   all_candidates	candidate	evaluatorbest_candidateremote_versiontypfinderrF   s	          r'   latest_infoz;ListCommand.iter_packages_latest_infos.<locals>.latest_info   s     "(!;!;D<O<O!P{{ *8&%(00>> "&N & #;;!%!4!4 < 	 "+!>!>~!N!)!/!7!7!&&//!C!C&4#'*$)&s   B5)_build_sessionrO   r   map)rC   rk   rF   rG   r   rs   r   s     `   @r'   rp   z&ListCommand.iter_packages_latest_infos   s}        ) !	W//AF+/08 K2 #J?!	 !	 !	s"   A)6AA	A)A&"A)c                    t        |d       }|j                  dk(  r$|r"t        ||      \  }}| j                  ||       y |j                  dk(  re|D ]_  }|j                  dk\  r-t        d|j                  |j                  |j                         ?t        d|j                  |j                         a y |j                  dk(  rt        t        ||             y y )	Nc                     | j                   S rS   )rz   )rs   s    r'   <lambda>z4ListCommand.output_package_listing.<locals>.<lambda>  s    T00 r&   )keyr4   r5      z%s==%s (%s)z%s==%sr6   )
sortedr3   format_for_columnsoutput_package_listing_columnsverboser   raw_namerq   locationformat_for_json)rC   rk   rF   dataheaderrs   s         r'   ri   z"ListCommand.output_package_listing  s     0
 )+-h@LD&//f=  H,  H??a' %t}}dllDMM !4==$,,GH   F*7;< +r&   r   r   c                     t        |      dkD  r|j                  d|       t        |      \  }}t        |      dkD  r(|j                  ddj                  d |D                     |D ]  }t	        |        y )Nr   r    c              3   &   K   | ]	  }d |z    yw)-Nr%   rT   xs     r'   rV   z=ListCommand.output_package_listing_columns.<locals>.<genexpr>,  s     *Bq37*Bs   )leninsertr   joinr   )rC   r   r   pkg_stringssizesvals         r'   r   z*ListCommand.output_package_listing_columns!  sn     t9q=KK6"%d^U t9q=q#((*BE*B"BC 	C	r&   )r*   N)r   r    r!   r"   ignore_require_venvusagerE   r   r   r   rO   r   r$   intrl   rg   rh   rf   r   rp   ri   r   r%   r&   r'   r)   r)   '   s    EV:p

(2
	
&'6 'c 's 'R
)
4:
	

)
4:
	
U)U4:U	U$)$4:$	4	5$L=)=4:=	=*cO-1#Y	r&   r)   pkgsrm   rF   r*   c                    ddg}|j                   }|r|j                  ddg       t        d | D              }|r|j                  d       |j                  dk\  r|j                  d       |j                  dk\  r|j                  d	       g }| D ]  }|j
                  t        |j                        g}|r?|j                  t        |j                               |j                  |j                         |r|j                  |j                  xs d
       |j                  dk\  r|j                  |j                  xs d
       |j                  dk\  r|j                  |j                         |j                  |        ||fS )z_
    Convert the package data into something usable
    by output_package_listing_columns.
    PackageVersionLatestTypec              3   4   K   | ]  }|j                     y wrS   )re   r   s     r'   rV   z%format_for_columns.<locals>.<genexpr>?  s     1q

1s   zEditable project locationr   Location	Installer )r\   extendanyappendr   r   r$   rq   r   r   editable_project_locationr   	installer)r   rF   r   running_outdatedhas_editablesr   projrows           r'   r   r   2  sF    #F''x()1D11M12!j!!k"D  }}c$,,/0JJs4../0JJt++,JJt55;<??aJJt}}*+??aJJt~~&C#& <r&   rk   c                    g }| D ]  }|j                   t        |j                        d}|j                  dk\  r"|j                  xs d|d<   |j
                  |d<   |j                  r't        |j                        |d<   |j                  |d<   |j                  }|r||d<   |j                  |        t        j                  |      S )	N)rx   rq   r   r   r   r   r   r   r   )r   r$   rq   r   r   r   r\   r   r   r   r   r6   dumps)rk   rF   r   rs   infor   s         r'   r   r   _  s    D MM4<<(
 ??a#}}2D $D%()<)<%=D!"&*&:&:D"#$($B$B!$0ID,-D ::dr&   )1r6   loggingoptparser   typingr   r   r   r   r   r	   r
   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   pip._internal.metadata.baser   r   rm   	getLoggerr   loggerr)   r$   r   r   r%   r&   r'   <module>r      s       R R R 9 ( ; 2 1 7 < D E 4 2 ;?.  23O 
		8	$H# HV*
*&,*
4S	?DI%&*Z/ & S r&   