
    k"g1              	          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)d dl*m+Z+  ejX                  e-      Z. G d de      Z/dddede
eee0      ee0   f   fdZ1dddede0fdZ2y)    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     T/var/www/html/djangosite/lib/python3.12/site-packages/pip/_internal/commands/list.pyr   r      s    	 ,+r&   r   )parsec                       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/   r0   z--prezYInclude pre-release and development versions. By default, pip only finds stable versions.z--formatstorelist_formatcolumns)r5   freezejsonzSelect the output format among: columns (default), freeze, or json. The 'freeze' format cannot be used with the --outdated option.)r.   r2   r/   choicesr0   z--not-requirednot_requiredz>List packages that are not dependencies of installed packages.)r.   r2   r0   z--exclude-editablestore_falseinclude_editablez%Exclude editable package from output.z--include-editablez%Include editable package from output.T)r.   r2   r0   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_options4   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.
        )rG   F)allow_yankedallow_all_prereleases)link_collectorselection_prefs)r   creater   prer   )rD   rG   rH   rL   rM   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.r6   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   r4   r   check_list_path_optionsetr   excludesupdater   pathiter_installed_distributionslocalr1   editabler;   r
   r9   get_not_requiredget_outdatedget_uptodateoutput_package_listingr   )rD   rG   rQ   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rl   _ProcessedDistsc           	          | j                  ||      D cg c]A  }t        t        |j                              t        t        |j                              kD  r|C c}S c c}w rT   iter_packages_latest_infosr(   r$   r   versionrD   rl   rG   dists       r'   rh   zListCommand.get_outdated   sW    
 77'J
S,,-.s4<<7H1II 
 	
 
   AAc           	          | j                  ||      D cg c]A  }t        t        |j                              t        t        |j                              k(  r|C c}S c c}w rT   rp   rs   s       r'   ri   zListCommand.get_uptodate   sW    
 77'J
S,,-.%DLL8I2JJ 
 	
 
ru   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)rD   rl   rG   rt   depdep_keyspkgs          r'   rg   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)Nrt   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_candidatesr{   rO   rr   is_prereleasemake_candidate_evaluatorsort_best_candidatelinkis_wheelr   r   )	rt   all_candidates	candidate	evaluatorbest_candidateremote_versiontypfinderrG   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_sessionrP   r   map)rD   rl   rG   rH   r   rt   r   s     `   @r'   rq   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 rT   )r{   )rt   s    r'   <lambda>z4ListCommand.output_package_listing.<locals>.<lambda>  s    T00 r&   )keyr5   r6      z%s==%s (%s)z%s==%sr7   )
sortedr4   format_for_columnsoutput_package_listing_columnsverboser   raw_namerr   locationformat_for_json)rD   rl   rG   dataheaderrt   s         r'   rj   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%   rU   xs     r'   rW   z=ListCommand.output_package_listing_columns.<locals>.<genexpr>.  s     *Bq37*Bs   )leninsertr   joinr   )rD   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usagerF   r   r   r   rP   r   r$   intrm   rh   ri   rg   r   rq   rj   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*   pkgsrn   rG   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rT   )rf   r   s     r'   rW   z%format_for_columns.<locals>.<genexpr>A  s     1q

1s   zEditable project locationr   Location	Installer )r]   extendanyappendr   r   r$   rr   r   r   editable_project_locationr   	installer)r   rG   r   running_outdatedhas_editablesr   projrows           r'   r   r   4  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&   rl   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)ry   rr   r   r   r   r   r   r   r   )r   r$   rr   r   r   r   r]   r   r   r   r   r7   dumps)rl   rG   r   rt   infor   s         r'   r   r   a  s    D MM4<<(
 ??a#}}2D $D%()<)<%=D!"&*&:&:D"#$($B$B!$0ID,-D ::dr&   )3r7   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   rn   pip._vendor.packaging.versionr(   	getLoggerr   loggerr*   r$   r   r   r%   r&   r'   <module>r      s       R R R 9 ( ; 2 1 7 < D E 4 2 ;?.  23O 0			8	$H# HV*
*&,*
4S	?DI%&*Z/ & S r&   