a
    ˆÀàg%3  ã                   @   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Zd dlZd dlmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ zd dlZW n ey¢   d dlZY n0 zd dlmZ W n eyÊ   dZY n0 d d	lmZ eZe ¡ Ze	d
ƒZG dd„ deƒZe�re�rdd„ Zndd„ Zne�r,dd„ Zndd„ Zej d%dd„ƒZ!dd„ Z"G dd„ dej#ƒZ$dd„ Z%G dd„ dej&ƒZ'G dd„ dej(j)ƒZ*G dd „ d eƒZ+G d!d"„ d"eƒZ,d#d$„ Z-dS )&é    )Úabsolute_importN)ÚFilterÚ	getLogger)ÚPY2)ÚWINDOWS)ÚDEPRECATION_MSG_PREFIX)Ú
ensure_dir)Úcolorama)ÚForezpip.subprocessorc                   @   s   e Zd ZdZdS )ÚBrokenStdoutLoggingErrorzO
    Raised if BrokenPipeError occurs for the stdout stream while logging.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   úT/var/www/sistema_ama/venv/lib/python3.9/site-packages/pip/_internal/utils/logging.pyr   :   s   r   c                 C   s   | t u o|jtjtjfv S ©z1See the docstring for non-Windows Python 3 below.)ÚIOErrorÚerrnoÚEINVALÚEPIPE©Ú	exc_classÚexcr   r   r   Ú_is_broken_pipe_errorH   s    ÿr   c                 C   s"   | t u p | tu o |jtjtjfv S r   )ÚBrokenPipeErrorÚOSErrorr   r   r   r   r   r   r   r   N   s    þc                 C   s   | t u o|jtjkS r   )r   r   r   r   r   r   r   r   T   s    c                 C   s   | t u S )z£
        Return whether an exception is a broken pipe error.

        Args:
          exc_class: an exception class.
          exc: an exception instance.
        )r   r   r   r   r   r   Y   s    é   c              	   c   sD   t ƒ t_t j| 7  _zdV  W t j| 8  _nt j| 8  _0 dS )zv
    A context manager which will cause the log output to be indented for any
    log messages emitted inside it.
    N)Úget_indentationÚ
_log_stateÚindentation)Únumr   r   r   Ú
indent_logd   s
    r"   c                   C   s   t tddƒS )Nr    r   )Úgetattrr   r   r   r   r   r   s   s    r   c                       s0   e Zd Z‡ fdd„Zdd„ Z‡ fdd„Z‡  ZS )ÚIndentingFormatterc                    s(   |  dd¡| _tt| ƒj|i |¤Ž dS )zÎ
        A logging.Formatter that obeys the indent_log() context manager.

        :param add_timestamp: A bool indicating output lines should be prefixed
            with their record's timestamp.
        Úadd_timestampFN)Úpopr%   Úsuperr$   Ú__init__)ÚselfÚargsÚkwargs©Ú	__class__r   r   r(   y   s    zIndentingFormatter.__init__c                 C   s.   |t jk rdS | t¡rdS |t jk r*dS dS )zv
        Return the start of the formatted log message (not counting the
        prefix to add to each line).
        Ú z	WARNING: zERROR: )ÚloggingÚWARNINGÚ
startswithr   ÚERROR)r)   Ú	formattedÚlevelnor   r   r   Úget_message_startƒ   s    


z$IndentingFormatter.get_message_startc                    s~   t t| ƒ |¡}|  ||j¡}|| }d‰ | jrN|  |d¡}djf i tƒ ¤Ž‰ ˆ dtƒ  7 ‰ d 	‡ fdd„| 
d¡D ƒ¡}|S )z†
        Calls the standard formatter, but will indent all of the log message
        lines by our current indentation level.
        r.   z%Y-%m-%dT%H:%M:%Sz{t},{record.msecs:03.0f} ú c                    s   g | ]}ˆ | ‘qS r   r   )Ú.0Úline©Úprefixr   r   Ú
<listcomp>¢   s   ÿz-IndentingFormatter.format.<locals>.<listcomp>T)r'   r$   Úformatr5   r4   r%   Ú
formatTimeÚlocalsr   ÚjoinÚ
splitlines)r)   Úrecordr3   Zmessage_startÚtr,   r9   r   r<   “   s    þzIndentingFormatter.format)r   r   r   r(   r5   r<   Ú__classcell__r   r   r,   r   r$   w   s   
r$   c                     s   ‡ fdd„}|S )Nc                    s   d  tˆ ƒ| tjjg ¡S )Nr.   )r?   Úlistr	   ÚStyleÚ	RESET_ALL)Úinp©Úcolorsr   r   Úwrappedª   s    z_color_wrap.<locals>.wrappedr   )rI   rJ   r   rH   r   Ú_color_wrap©   s    rK   c                       sh   e Zd Zer.ejeejƒfej	eej
ƒfgZng Zddd„Zdd„ Zdd„ Zdd	„ Z‡ fd
d„Z‡  ZS )ÚColorizedStreamHandlerNc                 C   s.   t j | |¡ || _tr*tr*t | j¡| _d S ©N)r/   ÚStreamHandlerr(   Ú	_no_colorr   r	   ÚAnsiToWin32Ústream)r)   rQ   Úno_colorr   r   r   r(   »   s    zColorizedStreamHandler.__init__c                 C   s"   t rtr| jjtju S | jtju S )zA
        Return whether the handler is using sys.stdout.
        )r   r	   rQ   rJ   ÚsysÚstdout©r)   r   r   r   Ú_using_stdoutÂ   s    z$ColorizedStreamHandler._using_stdoutc                 C   sX   t r
| jrdS t| jt jƒs"| jn| jj}t|dƒr@| ¡ r@dS tj	 
d¡dkrTdS dS )NFÚisattyTÚTERMZANSI)r	   rO   Ú
isinstancerQ   rP   rJ   ÚhasattrrW   ÚosÚenvironÚget)r)   Zreal_streamr   r   r   Úshould_colorÌ   s    
þz#ColorizedStreamHandler.should_colorc                 C   s@   t j | |¡}|  ¡ r<| jD ]\}}|j|kr||ƒ} q<q|S rM   )r/   rN   r<   r^   ÚCOLORSr4   )r)   rA   ÚmsgÚlevelÚcolorr   r   r   r<   á   s    
zColorizedStreamHandler.formatc                    s@   t  ¡ d d… \}}|r0|  ¡ r0t||ƒr0tƒ ‚tt| ƒ |¡S )Nr   )rS   Úexc_inforV   r   r   r'   rL   ÚhandleError)r)   rA   r   r   r,   r   r   rd   í   s    ÿz"ColorizedStreamHandler.handleError)NN)r   r   r   r	   r/   r2   rK   r
   ÚREDr0   ÚYELLOWr_   r(   rV   r^   r<   rd   rC   r   r   r,   r   rL   ¯   s   ý

rL   c                   @   s   e Zd Zdd„ ZdS )ÚBetterRotatingFileHandlerc                 C   s    t tj | j¡ƒ tjj | ¡S rM   )	r   r[   ÚpathÚdirnameÚbaseFilenamer/   ÚhandlersÚRotatingFileHandlerÚ_openrU   r   r   r   rm   ü   s    zBetterRotatingFileHandler._openN)r   r   r   rm   r   r   r   r   rg   ú   s   rg   c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚMaxLevelFilterc                 C   s
   || _ d S rM   )ra   )r)   ra   r   r   r   r(     s    zMaxLevelFilter.__init__c                 C   s   |j | jk S rM   )r4   ra   ©r)   rA   r   r   r   Úfilter  s    zMaxLevelFilter.filterN)r   r   r   r(   rp   r   r   r   r   rn     s   rn   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚExcludeLoggerFilterzQ
    A logging Filter that excludes records from a logger (or its children).
    c                    s   t t| ƒ |¡ S rM   )r'   rq   rp   ro   r,   r   r   rp     s    zExcludeLoggerFilter.filter)r   r   r   r   rp   rC   r   r   r,   r   rq   
  s   rq   c                 C   sd  | dkrd}n.| dkrd}n | dkr*d}n| dkr8d}nd	}t t|ƒ}|d
u}|r\|}d}nd}|}|dv rpdnd}dddœ}	dddœ}
g d¢|r˜dgng  }tj dddtjdœdtjdœdtjdœdœtddœtdddœd œ||
d! ||	d" d#d$gd%d&œd|
d! ||	d' d#gd%d&œ||
d! ||	d' d(gd%d&œd|
d) |dd*d+œd,œ||d-œd.d/|iid0œ¡ |S )1znConfigures and sets up all of the logging

    Returns the requested logging level, as its integer value.
    é   ÚDEBUGéÿÿÿÿr0   éþÿÿÿr2   éýÿÿÿÚCRITICALÚINFONz	/dev/null)rx   r2   zext://sys.stdoutzext://sys.stderr)rT   Ústderrz2pip._internal.utils.logging.ColorizedStreamHandlerz5pip._internal.utils.logging.BetterRotatingFileHandler)rQ   Úfile)ÚconsoleÚconsole_errorsÚconsole_subprocessÚuser_logFz*pip._internal.utils.logging.MaxLevelFilter)ú()ra   zlogging.Filter)r   Únamez/pip._internal.utils.logging.ExcludeLoggerFilter)Úexclude_warningsÚrestrict_to_subprocessÚexclude_subprocessz%(message)s)r   r<   T)r   r<   r%   )ÚindentÚindent_with_timestamprQ   rT   rƒ   r�   r„   )ra   ÚclassrR   rQ   ÚfiltersÚ	formatterry   r‚   rz   r…   )ra   r†   ÚfilenameÚdelayrˆ   )r{   r|   r}   r~   )ra   rk   zpip._vendorra   )ÚversionZdisable_existing_loggersr‡   Z
formattersrk   ÚrootZloggers)r#   r/   ÚconfigZ
dictConfigr0   Úsubprocess_loggerr€   r$   )Ú	verbosityrR   Zuser_log_filera   Zlevel_numberZinclude_user_logZadditional_log_fileZ
root_levelZvendored_log_levelZlog_streamsZhandler_classesrk   r   r   r   Úsetup_logging  s¨    
þþÿþþþ÷þýûú	úú	ûå$þÿÿ½Jr�   )r   ).Ú
__future__r   Ú
contextlibr   r/   Zlogging.handlersr[   rS   r   r   Zpip._vendor.sixr   Úpip._internal.utils.compatr   Zpip._internal.utils.deprecationr   Úpip._internal.utils.miscr   Ú	threadingÚImportErrorZdummy_threadingÚpip._vendorr	   Z	_coloramaÚ	ExceptionZpip._vendor.coloramar
   Úlocalr   rŽ   r   r   Úcontextmanagerr"   r   Ú	Formatterr$   rK   rN   rL   rk   rl   rg   rn   rq   r�   r   r   r   r   Ú<module>   sR   

		


2K	