
    Wh#                        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d.dZd/dZd0dZ	 	 	 	 	 	 	 	 	 d1d2d*Z d3d-Z!dS )4    )annotationsN)IterableMapping)AnyCallableLiteralUnion)escape)SpinnerInterfaceopen_spinner)InstallationSubprocessError)VERBOSEsubprocess_logger)
HiddenTextargsstr | HiddenText | CommandArgsreturnCommandArgsc                     g }| D ]B}t          |t                    r|                    |           -|                    |           C|S )z&
    Create a CommandArgs object.
    )
isinstancelistextendappend)r   command_argsargs      p/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/pip/_internal/utils/subprocess.pymake_commandr      sb     !#L % % c4   	%$$$$ $$$$    list[str] | CommandArgsstrc                @    d                     d | D                       S )z/
    Format command arguments for display.
     c              3     K   | ]N}t          |t                    r!t          j        t	          |                    nt          j        |          V  Od S )N)r   r   shlexquoter    .0r   s     r   	<genexpr>z&format_command_args.<locals>.<genexpr>.   sd         ",C!<!<RCHH%+cBRBR     r   )joinr   s    r   format_command_argsr+   %   s6     88       r   	list[str]c                    d | D             S )z=
    Return the arguments in their raw, unredacted form.
    c                J    g | ] }t          |t                    r|j        n|!S  )r   r   secretr&   s     r   
<listcomp>z'reveal_command_args.<locals>.<listcomp>8   s-    OOO3*S*55>CJJ3OOOr   r/   r*   s    r   reveal_command_argsr2   4   s     PO$OOOOr   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
          	        |g }|g }|rt           j        }t          j        }nt           j        }t
          }t          j                    |k    }| o|du} |d|
           t          j        	                                }|r|
                    |           |D ]}|                    |d           	 t          j        t          |           t          j        t          j        |	st          j        nt          j        ||d          }n+# t"          $ r}|rt          j        d||
            d}~ww xY wg }|	s|j        sJ |j        sJ |j                                         	 |j                                        }|snR|                                }|                    |dz               ||           |r|sJ |                                 n	 |                                 |j        r|j                                         n&# |j        r|j                                         w w xY wd                    |          }n|                                \  }}|                                D ]} ||           |                    |           |                                D ]} ||           |                    |           |}|j        o|j        |v}|r1|sJ |r|                    d	           n|                    d
           |r|dk    rtA          |
|j        |s|nd          }|rtt          j!        d|ddi           t          j        dtE          tG          |                     ddi           t          j        dtE          |pd          ddi           ||dk    rt          j$        d|
|j        |           n|dk    rntK          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stderrr7   enverrorsz#Error %s while executing command %sT
 errordoner3   )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Popenr2   PIPESTDOUT	ExceptioncriticalrJ   rI   closereadlinerstripr   spinwaitr)   communicate
splitlines
returncodefinishr   rP   r
   r+   warning
ValueError)r4   r5   r7   r9   r;   r=   r?   rA   rC   rE   rF   log_subprocess
used_levelshowing_subprocessuse_spinnerrL   nameprocexc
all_outputlineoutputouterrout_lineerr_lineproc_had_errorrP   s                               r   call_subprocessr   ;   s   6 #!   .?.D\

 +2
 +<>>*L )(@WD-@KN'666
*//

C "

=!!!  d$$/?,7L:$$Z_%	
 	
 	
     	&5  
 	 J #{z
	,,..D ;;==DdTk*** N4    		$IIKKK{ $!!### { $!!####$$$ ##%%S(( 	% 	%HN8$$$$#(( 	% 	%HN8$$$$#_T@T)TN # 	#NN7####NN6""" PG##/$0//AKZZt  E
  !'eFD>JJJJ!)@.s3344#T*   
 ").3-+..#T*    Kf$$%6	    h&&N]NNOOOMs%   2AD 
D/D**D/H #H*messageCallable[..., None]c                     	 	 dd f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.
    Nr4   r,   r7   r8   r=   r>   r   Nonec                    t                    5 }t          | |||           d d d            d S # 1 swxY w Y   d S )N)rF   r7   r=   rA   )r   r   )r4   r7   r=   rA   r   s       r   runnerz+runner_with_spinner_message.<locals>.runner   s    
 '"" 	g$+   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   377)NN)r4   r,   r7   r8   r=   r>   r   r   r/   )r   r   s   ` r   runner_with_spinner_messager      s5     26       Mr   )r   r   r   r   )r   r   r   r    )r   r   r   r,   )	FNr3   NNNNTF)r4   r   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rD   rF   r    r   r    )r   r    r   r   )"
__future__r   r[   r_   r$   rd   collections.abcr   r   typingr   r   r   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+   r2   r   r   r/   r   r   <module>r      s   " " " " " "  				      - - - - - - - - 0 0 0 0 0 0 0 0 0 0 0 0 * * * * * * E E E E E E E E @ @ @ @ @ @ B B B B B B B B / / / / / /5j)*   "   P P P P 8?15.2*.'+"&$e e e e eP     r   