o
    ©„j)#  ã                   @  sê   d dl mZ d dlZd dlZd dlZd dlZd dlmZmZm	Z	 d dl
mZmZ d dlmZ d dlmZmZ d dlmZ d dlmZmZ d d	lmZ eeeB  Zd3dd„Zd4dd„Zd5dd„Z									d6d7d-d.„Zd8d1d2„Z dS )9é    )ÚannotationsN)ÚCallableÚIterableÚMapping)ÚAnyÚLiteral)Úescape)ÚSpinnerInterfaceÚopen_spinner)ÚInstallationSubprocessError)ÚVERBOSEÚsubprocess_logger)Ú
HiddenTextÚargsústr | HiddenText | CommandArgsÚreturnÚCommandArgsc                  G  s2   g }| D ]}t |tƒr| |¡ q| |¡ q|S )z&
    Create a CommandArgs object.
    )Ú
isinstanceÚlistÚextendÚappend)r   Úcommand_argsÚarg© r   ú\/var/www/html/django_cbt/venv/lib/python3.10/site-packages/pip/_internal/utils/subprocess.pyÚmake_command   s   
r   úlist[str] | CommandArgsÚstrc                 C  s   d  dd„ | D ƒ¡S )z/
    Format command arguments for display.
    ú c                 s  s2   � | ]}t |tƒrt t|ƒ¡nt |¡V  qd S )N)r   r   ÚshlexÚquoter   ©Ú.0r   r   r   r   Ú	<genexpr>.   s
   €  ÿ
ÿz&format_command_args.<locals>.<genexpr>)Újoin©r   r   r   r   Úformat_command_args%   s   
	þr&   ú	list[str]c                 C  s   dd„ | D ƒS )z=
    Return the arguments in their raw, unredacted form.
    c                 S  s    g | ]}t |tƒr|jn|‘qS r   )r   r   Úsecretr!   r   r   r   Ú
<listcomp>8   s     z'reveal_command_args.<locals>.<listcomp>r   r%   r   r   r   Úreveal_command_args4   s   r*   FÚraiseTÚcmdÚshow_stdoutÚboolÚcwdú
str | NoneÚon_returncodeú"Literal['raise', 'warn', 'ignore']Úextra_ok_returncodesúIterable[int] | NoneÚextra_environúMapping[str, Any] | NoneÚunset_environúIterable[str] | NoneÚspinnerúSpinnerInterface | NoneÚlog_failed_cmdúbool | NoneÚstdout_onlyÚcommand_descc
             
   C  sÞ  |du rg }|du rg }|rt j}tj}nt j}t}t  ¡ |k}| o&|du}|d|
ƒ tj 	¡ }|r8| 
|¡ |D ]}| |d¡ q:ztjt| ƒtjtj|	sRtjntj||ddd�}W n tyr } z
|rmt  d||
¡ ‚ d}~ww g }|	sÈ|js|J ‚|js�J ‚|j ¡  	 |j ¡ }|s�n| ¡ }| |d ¡ ||ƒ |r¨|s¤J ‚| ¡  q‡z| ¡  W |jr·|j ¡  n
|jrÁ|j ¡  w w d	 |¡}n(| ¡ \}}| ¡ D ]}||ƒ qÒ| |¡ | ¡ D ]}||ƒ qâ| |¡ |}|jo÷|j|v}|�r|sÿJ ‚|�r| d
¡ n| d¡ |�rm|dk�rNt |
|j|�s|ndd�}|�rLt j!d|ddid� t jdt"t#| ƒƒddid� t jdt"|�pEdƒddid� |‚|dk�r^t  $d|
|j|¡ |S |dk�rf	 |S t%d|›�ƒ‚|S )aÍ  
    Args:
      show_stdout: if true, use INFO to log the subprocess's stderr and
        stdout streams.  Otherwise, use DEBUG.  Defaults to False.
      extra_ok_returncodes: an iterable of integer return codes that are
        acceptable, in addition to 0. Defaults to None, which means [].
      unset_environ: an iterable of environment variable names to unset
        prior to calling subprocess.Popen().
      log_failed_cmd: if false, failed commands are not logged, only raised.
      stdout_only: if true, return only stdout, else return both. When true,
        logging of both stdout and stderr occurs when the subprocess has
        terminated, else logging occurs as subprocess output is produced.
    NzRunning command %sÚlocaleÚbackslashreplace)ÚstdinÚstdoutÚstderrr/   ÚenvÚencodingÚerrorsz#Error %s while executing command %sTÚ
Ú ÚerrorÚdoner+   )Úcommand_descriptionÚ	exit_codeÚoutput_linesz%sÚrich)Úextraz*[bold magenta]full command[/]: [blue]%s[/]Úmarkupz[bold magenta]cwd[/]: %sz	[inherit]Úwarnz$Command "%s" had error code %s in %sÚignorezInvalid value: on_returncode=)&r   ÚinfoÚloggingÚINFOÚverboser   ÚgetEffectiveLevelÚosÚenvironÚcopyÚupdateÚpopÚ
subprocessÚPopenr*   ÚPIPEÚSTDOUTÚ	ExceptionÚcriticalrB   rA   ÚcloseÚreadlineÚrstripr   ÚspinÚwaitr$   ÚcommunicateÚ
splitlinesÚ
returncodeÚfinishr   rI   r   r&   ÚwarningÚ
ValueError)r,   r-   r/   r1   r3   r5   r7   r9   r;   r=   r>   Úlog_subprocessÚ
used_levelÚshowing_subprocessÚuse_spinnerrD   ÚnameÚprocÚexcÚ
all_outputÚlineÚoutputÚoutÚerrÚout_lineÚerr_lineÚproc_had_errorrI   r   r   r   Úcall_subprocess;   sÜ   



÷ý€ù



ô

€ÿÿ





ý
ýý
ü

üÿr}   ÚmessageúCallable[..., None]c                   s   		dd‡ fd
d„}|S )zßProvide a subprocess_runner that shows a spinner message.

    Intended for use with for BuildBackendHookCaller. Thus, the runner has
    an API that matches what's expected by BuildBackendHookCaller.subprocess_runner.
    Nr,   r'   r/   r0   r5   r6   r   ÚNonec                   s@   t ˆ ƒ�}t| ˆ |||d� W d   ƒ d S 1 sw   Y  d S )N)r>   r/   r5   r9   )r
   r}   )r,   r/   r5   r9   ©r~   r   r   Úrunnerë   s   
û"ÿz+runner_with_spinner_message.<locals>.runner)NN)r,   r'   r/   r0   r5   r6   r   r€   r   )r~   r‚   r   r�   r   Úrunner_with_spinner_messageä   s   	ýrƒ   )r   r   r   r   )r   r   r   r   )r   r   r   r'   )	FNr+   NNNNTF)r,   r   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r<   r>   r   r   r   )r~   r   r   r   )!Ú
__future__r   rT   rX   r   r]   Úcollections.abcr   r   r   Útypingr   r   Úpip._vendor.rich.markupr   Úpip._internal.cli.spinnersr	   r
   Úpip._internal.exceptionsr   Úpip._internal.utils.loggingr   r   Úpip._internal.utils.miscr   r   r   r   r   r&   r*   r}   rƒ   r   r   r   r   Ú<module>   s8    


	ö *