o
    ­—Žj×$  ã                   @  sX  d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	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 dd
lmZmZ ddlmZmZmZmZmZ ddlmZm Z m!Z!m"Z"m#Z#m$Z$ ddl%m&Z& ddl'm(Z(m)Z) ddl*m+Z+m,Z, ddl-m.Z/ ddl-m0Z0m1Z1 ddl2m3Z3 dgZ4e 5e6¡Z7G dd„ deƒZ8dS )z(Base Command class, and related routinesé    )ÚannotationsN)ÚCallableÚIterator)ÚValues)Úreconfigure)Ú	traceback)Ú
cmdoptions)ÚCommandContextMixIn)ÚConfigOptionParserÚUpdatingDefaultsHelpFormatter)ÚBROKEN_STDOUTÚERRORÚPREVIOUS_BUILD_DIR_ERRORÚUNKNOWN_ERRORÚVIRTUALENV_NOT_FOUND)Ú
BadCommandÚCommandErrorÚDiagnosticPipErrorÚInstallationErrorÚNetworkConnectionErrorÚPreviousBuildDirError)Úcheck_path_owner)ÚBrokenStdoutLoggingErrorÚsetup_logging)Úget_progÚnormalize_path)ÚTempDirectoryTypeRegistry)Úglobal_tempdir_managerÚtempdir_registry)Úrunning_under_virtualenvÚCommandc                      s�   e Zd ZU dZded< dZded< d'd(‡ fdd„Zd)dd„Zej	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‡  ZS )0r    Ú ÚstrÚusageFÚboolÚignore_require_venvÚnameÚsummaryÚisolatedÚreturnÚNonec              	     sŽ   t ƒ  ¡  || _|| _t| jtƒ › d|› �tƒ d|| j|d�| _	d | _
| j ¡ › d�}t | j	|¡| _t tj| j	¡}| j	 |¡ |  ¡  d S )Nú F)r#   ÚprogÚ	formatterÚadd_help_optionr&   Údescriptionr(   z Options)ÚsuperÚ__init__r&   r'   r
   r#   r   r   Ú__doc__Úparserr   Ú
capitalizeÚoptparseÚOptionGroupÚcmd_optsr   Úmake_option_groupÚgeneral_groupÚadd_option_groupÚadd_options)Úselfr&   r'   r(   Úoptgroup_nameÚgen_opts©Ú	__class__© ú[/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pip/_internal/cli/base_command.pyr1   4   s*   
ù
þzCommand.__init__c                 C  s   d S ©NrA   ©r<   rA   rA   rB   r;   R   ó   zCommand.add_optionsÚoptionsr   Úargsú	list[str]úIterator[None]c                 c  s   � t |dƒrJ ‚dV  dS )zf
        This is a no-op so that commands by default do not do the pip version
        check.
        Úno_indexN)Úhasattr©r<   rF   rG   rA   rA   rB   Úpip_version_checkU   s   €
zCommand.pip_version_checkÚintc                 C  s   t ‚rC   )ÚNotImplementedErrorrL   rA   rA   rB   Úrun`   rE   zCommand.runÚlevel_numberc           	        sN  d‡ ‡‡fdd„}ˆj rtjdd� |ƒ S z|ƒ }t|tƒs J ‚|W S  tyG } ztjd|ddid	� tjd
dd� t	W  Y d }~S d }~w t
yh } zt t|ƒ¡ tjd
dd� tW  Y d }~S d }~w tttfyŒ } zt t|ƒ¡ tjd
dd� t	W  Y d }~S d }~w ty¬ } zt d|¡ tjd
dd� t	W  Y d }~S d }~w tyý   z"t dd¡ |tjkrÓttjdd ƒpÆd}t dt ¡  |d¡¡ W n	 tyÝ   Y nw t tjtj ¡}zt !|d¡ W t "|¡ t# Y S t "|¡ w  t$�y   t d¡ tjd
dd� t	 Y S  t%�y&   tjddd� t& Y S w )Nr)   rN   c                     s<   ˆ  ˆˆ ¡� ˆ ˆˆ ¡W  d   ƒ S 1 sw   Y  d S rC   )rM   rP   rA   ©rG   rF   r<   rA   rB   Ú
_inner_rund   s   
$ÿz(Command._run_wrapper.<locals>._inner_runT)Úshow_localsz%sÚrich)ÚextrazException information:)Úexc_infoé   s!   ERROR: Pipe to stdout was broken
Úencodingzutf-8Úbackslashreplaceé   zOperation cancelled by userz
Exception:)r)   rN   )'Ú
debug_modeÚrich_tracebackÚinstallÚ
isinstancerN   r   ÚloggerÚerrorÚdebugr   r   Úcriticalr"   r   r   r   r   r   r   ÚosÚwriteÚloggingÚDEBUGÚgetattrÚsysÚstderrr   Ú
format_excÚencodeÚOSErrorÚopenÚdevnullÚO_WRONLYÚdup2Úcloser   ÚKeyboardInterruptÚBaseExceptionr   )	r<   rQ   rF   rG   rS   ÚstatusÚexcrY   ro   rA   rR   rB   Ú_run_wrapperc   st   €€ý€€
ÿ€ÿ
þ
ýzCommand._run_wrapperútuple[Values, list[str]]c                 C  s   | j  |¡S rC   )r3   Ú
parse_args©r<   rG   rA   rA   rB   ry   ©   s   zCommand.parse_argsc                 C  sV   z%|   ¡ � |  |¡W  d   ƒ W t ¡  S 1 sw   Y  W t ¡  d S t ¡  w rC   )Úmain_contextÚ_mainrf   Úshutdownrz   rA   rA   rB   Úmain­   s   
ÿ
ýzCommand.mainc                 C  sh  |   tƒ ¡| _|   tƒ ¡ |  |¡\}}|j|j | _|jr!d| _t|dƒr5|j	dkr5| jdkr2dnd|_	t
|jd� t| j|j|jd�}t|jƒttjƒ@ }|r\t d	d
 t|ƒ¡¡ |jrndtjvrnt d¡ t t¡ |jrvdtjd< |jr‚d |j¡tjd< |jr•| j s•t!ƒ s•t d¡ t t"¡ |j#r­t$|j#ƒ|_#t%|j#ƒs­t d|j#¡ d |_#|  &|||¡S )NrX   Úprogress_barÚautor   ÚonÚoff)Úno_color)Ú	verbosityrƒ   Úuser_log_filez/The following features are always enabled: %s. z, Ú_PIP_RUNNING_IN_SUBPROCESSzAThe --python option must be placed before the pip subcommand nameÚ1ÚPIP_NO_INPUTr+   ÚPIP_EXISTS_ACTIONz2Could not find an activated virtualenv (required).zêThe directory '%s' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.)'Úenter_contextr   r   ry   ÚverboseÚquietr„   r\   rK   r   r   rƒ   r   ÚlogÚsetÚfeatures_enabledr   ÚALWAYS_ENABLED_FEATURESr`   ÚwarningÚjoinÚsortedÚpythonrd   Úenvironrc   ri   Úexitr   Úno_inputÚexists_actionÚrequire_venvr%   r   r   Ú	cache_dirr   r   rw   )r<   rG   rF   rQ   Úalways_enabled_featuresrA   rA   rB   r|   ´   sX   ý
ÿþ
ÿ




úzCommand._mainú.dict[str, Callable[[Values, list[str]], None]]c                 C  s   i S )zO
        map of names to handler actions for commands with sub-actions
        rA   rD   rA   rA   rB   Úhandler_map  s   zCommand.handler_map)F)r&   r"   r'   r"   r(   r$   r)   r*   )r)   r*   )rF   r   rG   rH   r)   rI   )rF   r   rG   rH   r)   rN   )rQ   rN   rF   r   rG   rH   r)   rN   )rG   rH   r)   rx   )rG   rH   r)   rN   )r)   rœ   )Ú__name__Ú
__module__Ú__qualname__r#   Ú__annotations__r%   r1   r;   Ú
contextlibÚcontextmanagerrM   rP   rw   ry   r~   r|   r�   Ú__classcell__rA   rA   r?   rB   r    0   s   
 




F

M)9r2   Ú
__future__r   r¢   rf   Úlogging.configr5   rd   ri   r   Úcollections.abcr   r   r   Úpip._vendor.richr   r]   Úpip._internal.clir   Ú!pip._internal.cli.command_contextr	   Úpip._internal.cli.parserr
   r   Úpip._internal.cli.status_codesr   r   r   r   r   Úpip._internal.exceptionsr   r   r   r   r   r   Úpip._internal.utils.filesystemr   Úpip._internal.utils.loggingr   r   Úpip._internal.utils.miscr   r   Úpip._internal.utils.temp_dirr   ÚTempDirRegistryr   r   Úpip._internal.utils.virtualenvr   Ú__all__Ú	getLoggerrž   r`   r    rA   rA   rA   rB   Ú<module>   s6     
