a
    RHh#                     @   sh  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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 d dlmZmZ d dlmZ eeeef  Zeeeef edd	d
Zeee ef edddZeee ef ee dddZdeee ef eee deee  ee
eef  eee  ee ee ee eedddZ eed dddZ!dS )    N)AnyCallableIterableListLiteralMappingOptionalUnion)escape)SpinnerInterfaceopen_spinner)InstallationSubprocessError)VERBOSEsubprocess_logger)
HiddenText)argsreturnc                  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   a/var/www/viveiro_nova_floresta/venv/lib/python3.9/site-packages/pip/_internal/utils/subprocess.pymake_command   s    
r   c                 C   s   d dd | D S )z/
    Format command arguments for display.
     c                 s   s0   | ](}t |trtt|nt|V  qd S )N)r   r   shlexquotestr.0r   r   r   r   	<genexpr>+   s   z&format_command_args.<locals>.<genexpr>)joinr   r   r   r   format_command_args"   s    	
r$   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>5       z'reveal_command_args.<locals>.<listcomp>r   r#   r   r   r   reveal_command_args1   s    r(   FraiseTz"Literal["raise", "warn", "ignore"])cmdshow_stdoutcwdon_returncodeextra_ok_returncodesextra_environunset_environspinnerlog_failed_cmdstdout_onlycommand_descr   c
             
   C   s  |du rg }|du rg }|r*t j}tj}n
t j}t}t  |k}| oL|du}|d|
 tj	 }|rp|
| |D ]}||d qtz0tjt| tjtj|	stjntj||dd}W n8 ty } z |rt d||
  W Y d}~n
d}~0 0 g }|	s|jsJ |jsJ |j  |j }|s0qj| }||d  || |r|s^J |  qz|  W |jr|j  n|jr|j  0 d|}nT| \}}| D ]}|| q|| | D ]}|| q|| |}|jo|j|v}|r<|s J |r2|d n
|d	 |r|d
krt |
|j|s^|ndd}|rt j!d|ddid t jdt"t#| ddid t jdt"|pdddid |n8|dkrt $d|
|j| n|dkrn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 %s
 errordoner)   )command_description	exit_codeoutput_linesz%srichT)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criticalr7   r6   closereadlinerstripr   spinwaitr"   communicate
splitlines
returncodefinishr   r=   r
   r$   warning
ValueError)r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   Zlog_subprocessZ
used_levelZshowing_subprocessZuse_spinnerr9   nameprocexcZ
all_outputlineoutputouterrZout_lineZerr_lineZproc_had_errorr=   r   r   r   call_subprocess8   s    
















ri   ).N)messager   c                    s2   dt t tt ttttf  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.
    N)r*   r,   r/   r   c                    s>   t  "}t|  |||d W d    n1 s00    Y  d S )N)r4   r,   r/   r1   )r   ri   )r*   r,   r/   r1   rj   r   r   runner   s    
z+runner_with_spinner_message.<locals>.runner)NN)r   r   r   r   r   )rj   rl   r   rk   r   runner_with_spinner_message   s    	  rm   )	FNr)   NNNNTF)"rH   rL   r   rQ   typingr   r   r   r   r   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   ZCommandArgsr   r$   r(   boolintri   rm   r   r   r   r   <module>   sL   ( 	         

 )