o
    Uh#                     @  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 d dl	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 d dlmZmZ d d	lmZ eeeef  Zd3ddZd4ddZd5ddZ									d6d7d-d.Z d8d1d2Z!dS )9    )annotationsN)IterableMapping)AnyCallableLiteralUnion)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   Zcommand_argsarg r   f/var/www/html/figdemos/bartoux_crm/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}W n tyq } z
|rlt d||
  d}~ww g }|	s|js{J |jsJ |j  	 |j }|sn| }||d  || |r|sJ |  qz|  W |jr|j  n
|jr|j  w w d|}n(| \}}| D ]}|| q|| | D ]}|| q|| |}|jo|j|v}|r|sJ |r|d	 n|d
 |rl|dkrMt |
|j|s|ndd}|rKt j!d|ddid t jdt"t#| ddid t jdt"|pDdddid ||dkr]t $d|
|j| |S |dkre	 |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backslashreplace)stdinstdoutstderrr/   env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criticalrA   r@   closereadlinerstripr   spinwaitr$   communicate
splitlines
returncodefinishr   rG   r	   r&   warning
ValueError)r,   r-   r/   r1   r3   r5   r7   r9   r;   r=   r>   Zlog_subprocessZ
used_levelZshowing_subprocessZuse_spinnerrC   nameprocexcZ
all_outputlineoutputouterrZout_lineZerr_lineZproc_had_errorrG   r   r   r   call_subprocess;   s   




















rs   messageCallable[..., None]c                   s   		dd fd
d}|S )zProvide 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   rs   )r,   r/   r5   r9   rt   r   r   runner   s   
"z+runner_with_spinner_message.<locals>.runner)NN)r,   r'   r/   r0   r5   r6   r   rv   r   )rt   rx   r   rw   r   runner_with_spinner_message   s   	ry   )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   )rt   r   r   ru   )"
__future__r   rR   rV   r   r[   collections.abcr   r   typingr   r   r   r   Z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*   rs   ry   r   r   r   r   <module>   s8    


	 )