
    ܖi-	              	           d Z ddlZddlZddlmZ ddlmZ ddlmZ  G d de	      Z
d	 e       d
dee   dededefdZy)zl
A thin `subprocess` wrapper for making long-running subprocesses more
responsive from the `pip-audit` CLI.
    N)Sequence)Popen   )
AuditStatec                   0     e Zd ZdZdededdf fdZ xZS )CalledProcessErrorzY
    Raised if the underlying subprocess created by `run` exits with a nonzero code.
    msgstderrreturnNc                2    t         |   |       || _        y)z4
        Create a new `CalledProcessError`.
        N)super__init__r
   )selfr	   r
   	__class__s      Y/var/www/html/content-pipeline/venv/lib/python3.12/site-packages/pip_audit/_subprocess.pyr   zCalledProcessError.__init__   s     	    )__name__
__module____qualname____doc__strr   __classcell__)r   s   @r   r   r      s'    C C D  r   r   F)
log_stdoutstateargsr   r   r   c                   dj                  t        j                  j                  | d         g| dd       }d}d}d}t	        | dt
        j                  t
        j                        5 }|sx|j                         du}||j                  j                         z  }||j                  j                         z  }|j                  d| |r|j                  d	
      nd       |sx|j                  dk7  r,t        | d|j                   |j                  d	
            	 ddd       |j                  dd	
      S # 1 sw Y   xY w)z
    Execute the given arguments.

    Uses `state` to provide feedback on the subprocess's status.

    Raises a `CalledProcessError` if the subprocess fails. Otherwise, returns
    the process's `stdout` stream as a string.
     r   r   NFr   )bufsizestdoutr
   zRunning replace)errorsz exited with )r
   zutf-8)joinospathbasenamer   
subprocessPIPEpollr   readr
   update_statedecode
returncoder   )r   r   r   pretty_args
terminatedr   r
   processs           r   runr0      s>    ((BGG,,T!W5AQRABKJFF 
tQzz	O SZ  t3Jgnn))++Fgnn))++F;-(3=Y/4	  "$-}W-?-?,@A}}I}6  #& ===33' s   )A:D;$;D;;E)r   os.pathr#   r&   collections.abcr   r   _stater   	Exceptionr   r   boolr0    r   r   <module>r7      sV   
   $  
 
 49jl (4hsm (4D (4 (4_b (4r   