HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/sphinx/util/__pycache__/logging.cpython-310.pyc
o

u�a�G�
@s�UdZddlZddlZddlmZddlmZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZddlmZddlmZddlmZdd	lmZdd
lmZe	rUddlmZdZd
Zedd��Z ee!e"fe#d<e �$ej%ej%ej&ej'ej(eej)d��edd��Z*ee"e"fe#d<e*�$ej(eej)d��edd�ej&dej'dej)di�Z+de!ddfdd�Z,de
ej-ddfdd �Z.Gd!d"�d"ej-�Z/Gd#d$�d$e/�Z0Gd%d&�d&e/�Z1Gd'd�dej2�Z3Gd(d)�d)ej4�Z5Gd*d+�d+ej4�Z6Gd,d-�d-ej7j8�Z9edeej:ddffd.d/��Z;edee9ddffd0d1��Z<edee9ddffd2d3��Z=eddd5e>ded6fd7d8��Z?ed9e!ded6fd:d;��Z@Gd<d=�d=�ZAGd>d?�d?ejB�ZCd@e!dAe!dBe
e!de>fdCdD�ZDGdEdF�dFejB�ZEGdGdH�dHejB�ZFGdIdJ�dJejB�ZGGdKdL�dLejB�ZHGdMdN�dNejB�ZIGdOdP�dPejB�ZJGdQdR�dReJ�ZKGdSdT�dTeJ�ZLdUedee!fdVdW�ZMGdXdY�dYejN�ZOGdZd[�d[�ZPGd\d]�d]�ZQd^d_d`edaeddfdbdc�ZRdS)ez�
    sphinx.util.logging
    ~~~~~~~~~~~~~~~~~~~

    Logging utility functions for Sphinx.

    :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�defaultdict)�contextmanager)
�IO�
TYPE_CHECKING�Any�Dict�	Generator�List�Optional�Tuple�Type�Union)�nodes)�Node��get_source_line)�
SphinxWarning)�colorize)�Sphinx�sphinx�cCstjS�N)�logging�WARNING�rr�5/usr/lib/python3/dist-packages/sphinx/util/logging.py�<lambda>sr�LEVEL_NAMES)�CRITICAL�SEVERE�ERRORr�INFO�VERBOSE�DEBUGcC�dS)Nrrrrrrr*��
VERBOSITY_MAP)r��cCr$)N�bluerrrrrr1r%�darkred�red�darkgray�name�return�SphinxLoggerAdaptercCs"t�td|�}d|_t|i�S)a�Get logger wrapped by :class:`sphinx.util.logging.SphinxLoggerAdapter`.

    Sphinx logger always uses ``sphinx.*`` namespace to be independent from
    settings of root logger.  It ensures logging is consistent even if a
    third-party extension or imported application resets logger settings.

    Example usage::

        >>> from sphinx.util import logging
        >>> logger = logging.getLogger(__name__)
        >>> logger.info('Hello, this is an extension!')
        Hello, this is an extension!
    �.F)r�	getLogger�	NAMESPACE�disabledr/)r-�loggerrrrr19s
r1�recordscCs@|D]}|��|_d|_t|dd�}t|tj�rt|�|_qdS)zConvert LogRecord serializable.r�locationN)	�
getMessage�msg�args�getattr�
isinstancerr�get_node_locationr6)r5�rr6rrr�convert_serializableOs

��r>cs8eZdZUdZdZdZeed<def�fdd�Z	�Z
S)�SphinxLogRecordz$Log record class supporting location�Nr6r.csFt���}t|dd�}|rd||j|f}|S|j|vr!|j|}|S)Nr6z%s: %s%s)�superr7r:�prefix)�self�messager6��	__class__rrr7`s

�
zSphinxLogRecord.getMessage)�__name__�
__module__�__qualname__�__doc__rBr6r�__annotations__�strr7�
__classcell__rrrErr?[s

r?c@�eZdZdZdZdS)�SphinxInfoLogRecordz)Info log record class supporting locationr@N�rGrHrIrJrBrrrrrOk�rOc@rN)�SphinxWarningLogRecordz,Warning log record class supporting locationz	WARNING: NrPrrrrrRprQrRc
s�eZdZdZgd�Zdeeefdedededdf
�fd	d
�Z	dedededdfdd�Z
dededeeeffd
d�Z
dejddfdd�Z�ZS)r/z9LoggerAdapter allowing ``type`` and ``subtype`` keywords.)�type�subtyper6�nonl�color�once�levelr8r9�kwargsr.NcsRt|t�rt�j||g|�Ri|��dSt|}t�j||g|�Ri|��dSr)r;�intrA�logr)rCrXr8r9rY�levelnorErrr[ys
  zSphinxLoggerAdapter.logcOs|jt|g|�Ri|��dSr)r[r")rCr8r9rYrrr�verbose�szSphinxLoggerAdapter.verbosecCs6|�di�}|jD]
}||vr|�|�||<q	||fS)N�extra)�
setdefault�KEYWORDS�pop)rCr8rYr^�keywordrrr�process�s
�zSphinxLoggerAdapter.process�recordcCs|j�|�dSr)r4�handle�rCrdrrrre��zSphinxLoggerAdapter.handle)rGrHrIrJr`r
rZrLrr[r]rrrcr�	LogRecordrerMrrrErr/us*c@seZdZdZdS)�WarningStreamHandlerzStreamHandler for warnings.N)rGrHrIrJrrrrri�srics,eZdZdZdejddf�fdd�Z�ZS)�NewLineStreamHandlerzAStreamHandler which switches line terminator by record.nonl flag.rdr.NcsLz|��t|dd�rd|_t��|�Wd|_|��dSd|_|��w)NrUFr@�
)�acquirer:�
terminatorrA�emit�releaserfrErrrn�s�
zNewLineStreamHandler.emit)rGrHrIrJrrhrnrMrrrErrj�s rjcsxeZdZUdZeejed<d�fdd�Zdejde	fdd	�Z
dd
d�Zdejddfd
d�Z
deejfdd�Z�ZS)�
MemoryHandlerzHandler buffering all logs.�bufferr.Ncst��d�dS)N���)rA�__init__�rCrErrrs�rgzMemoryHandler.__init__rdcCr$)NFrrfrrr�shouldFlush�szMemoryHandler.shouldFlushcCsdSrrrtrrr�flush�szMemoryHandler.flushr4cCs>|��z|jD]}|�|�qg|_W|��dS|��wr)rlrqrero)rCr4rdrrr�flushTo�s
zMemoryHandler.flushTocCs|jg}|_|Sr)rq)rCrqrrr�clear�szMemoryHandler.clear�r.N)rGrHrIrJr	rrhrKrs�boolrurv�LoggerrwrxrMrrrErrp�s

	rpc
cs��t�t�}t�}|�tj�z:g}|jdd�D]}t|t�r*|�	|�|�
|�q|�|�|VW|�	|�|D]}|�|�q;|�|�dS|�	|�|D]}|�|�qQ|�|�w)zgContext manager to postpone logging warnings temporarily.

    Similar to :func:`pending_logging`.
    N)
rr1r2rp�setLevelr�handlersr;ri�
removeHandler�append�
addHandlerrw�r4�
memhandlerr}�handlerrrr�pending_warnings�s*�



�


�r�c
cs��t�t�}t�}z0g}|jdd�D]}|�|�|�|�q|�|�|VW|�|�|D]}|�|�q0dS|�|�|D]}|�|�qAw)z�Context manager to suppress logging all logs temporarily.

    For example::

        >>> with suppress_logging():
        >>>     logger.warning('Warning message!')  # suppressed
        >>>     some_long_process()
        >>>
    N)rr1r2rpr}r~rr�r�rrr�suppress_logging�s$�



�
��r�c	csf�t�t�}z&t��}|VWd�n1swYW|�|�dSW|�|�dS|�|�w)a$Context manager to postpone logging all logs temporarily.

    For example::

        >>> with pending_logging():
        >>>     logger.warning('Warning message!')  # not flushed yet
        >>>     some_long_process()
        >>>
        Warning message!  # the warning is flushed here
    N)rr1r2r�rw)r4r�rrr�pending_logging�s�
��r�T�skip�NNNc
csz�t�t�}|durdVdSz!t�}|jD]	}|j�d|�qdVW|jD]}|�|�q'dS|jD]}|�|�q4w)z9Context manager to skip WarningIsErrorFilter temporarily.FNr)rr1r2�DisableWarningIsErrorFilterr}�filters�insert�removeFilter)r�r4�disablerr�rrr�skip_warningiserrors�



��r�rBc	cs��t�t�}d}|jD]}t|t�r|}nqdVdSd}|jD]}t|t�r,|}nq!|rCz|j}||_dVW||_dS||_wt|�}z|�	|�dVW|�
|�dS|�
|�w)z�Context manager to prepend prefix to all warning log records temporarily.

    For example::

        >>> with prefixed_warnings("prefix:"):
        >>>     logger.warning('Warning message!')  # => prefix: Warning message!

    .. versionadded:: 2.0
    N)rr1r2r}r;rir��MessagePrefixFilterrB�	addFilterr�)rBr4�warning_handlerr��
prefix_filter�_filter�previousrrr�prefixed_warnings"s6�


�

�
r�c@s,eZdZddd�Zededfdd��ZdS)	�LogCollectorr.NcCs
g|_dSr)�logsrtrrrrsQ�
zLogCollector.__init__r�ccs>�t��}dV|��|_Wd�dS1swYdSr)r�rxr�)rCr�rrr�collectTs
�"�zLogCollector.collectry)rGrHrIrsrrr�rrrrr�Ps
r�c@�$eZdZdZdejdefdd�ZdS)�
InfoFilterz"Filter error and warning messages.rdr.cCs|jtjkrdSdS)NTF)r\rrrfrrr�filter_szInfoFilter.filterN�rGrHrIrJrrhrzr�rrrrr�\�r�rSrT�suppress_warningscCst|durdS|D]/}d|vr|�dd�\}}n|d}}||kr7|dur(|dus4|dus4||ks4|dkr7dSqdS)z/Check whether the warning is suppressed or not.NFr0r'�*T)�split)rSrTr��warning_type�target�	subtargetrrr�is_suppressed_warningfs
�r�c�6eZdZdZd�fdd�Zdejdefd	d
�Z�Z	S)�WarningSuppressorz#Filter logs by `suppress_warnings`.�apprr.Nc�||_t���dSr�r�rArs�rCr�rErrrs��zWarningSuppressor.__init__rdcCsbt|dd�}t|dd�}z|jjj}Wntyg}Ynwt|||�r'dS|jjd7_dS)NrSrTFr'T)r:r��configr��AttributeErrorr��
_warncount)rCrdrSrTr�rrrr��s�zWarningSuppressor.filter�r�rr.N�
rGrHrIrJrsrrhrzr�rMrrrErr�}�r�cr�)�WarningIsErrorFilterz#Raise exception if warning emitted.r�rr.Ncr�rr�r�rErrrs�r�zWarningIsErrorFilter.__init__rdc	Cs�t|dd�rdS|jjrGt|dd�}z|j|j}Wnttfy(|j}Ynw|r6t|dt|��}nt|�}|j	durE||j	d�|�dS)N�skip_warningsiserrorFTr6r@�:r')
r:r��warningiserrorr8r9�	TypeError�
ValueErrorrrL�exc_info)rCrdr6rD�excrrrr��s 
�
zWarningIsErrorFilter.filterr�r�rrrErr��r�r�c@r�)r�z6Disable WarningIsErrorFilter if this filter installed.rdr.cCs
d|_dS)NT)r�rfrrrr��sz"DisableWarningIsErrorFilter.filterNr�rrrrr��r�r�cs>eZdZdZdeddf�fdd�Zdejdefdd	�Z	�Z
S)
r�z"Prepend prefix to all log records.rBr.Ncr�r)rBrArs)rCrBrErrrs�r�zMessagePrefixFilter.__init__rdcCs|jr|jd|j|_dS)N� T)rBr8rfrrrr��szMessagePrefixFilter.filter�rGrHrIrJrLrsrrhrzr�rMrrrErr��sr�cs@eZdZdZddeddf�fdd�
Zdejdefd	d
�Z	�Z
S)�
OnceFilterzShow the message only once.r@r-r.Ncst��|�i|_dSr)rArs�messages)rCr-rErrrs�s
zOnceFilter.__init__rdcCsBt|dd�}|s
dS|j�|jg�}|j|vrdS|�|j�dS)NrWr@TF)r:r�r_r8r9r)rCrdrW�paramsrrrr��s
zOnceFilter.filter)r@r�rrrErr��sr�csDeZdZUdZeejed<d�fdd�Zd	e	de
fd
d�Z�ZS)
�SphinxLogRecordTranslatorz�Converts a log record to one Sphinx expects

    * Make a instance of SphinxLogRecord
    * docname to path if location given
    �LogRecordClassr�rr.Ncr�rr�r�rErrrs�r�z"SphinxLogRecordTranslator.__init__rdcCs�t|tj�r
|j|_t|dd�}t|t�r>|\}}|r+|r+d|jj�	|�|f|_
dS|r9d|jj�	|�|_
dSd|_
dSt|tj�rKt
|�|_
dS|r[d|vr[d|jj�	|�|_
dS)Nr6�%s:%sz%sr�T)r;rrhr�rFr:�tupler��env�doc2pathr6rrr<)rCrdr6�docname�linenorrrr��s&

���
�z SphinxLogRecordTranslator.filterr�)
rGrHrIrJrrrhrKrsrRrzr�rMrrrErr��s

r�c@�eZdZdZeZdS)�InfoLogRecordTranslatorz/LogRecordTranslator for INFO level log records.N)rGrHrIrJrOr�rrrrr��rQr�c@r�)�WarningLogRecordTranslatorz2LogRecordTranslator for WARNING level log records.N)rGrHrIrJrRr�rrrrr�rQr��nodecCs<t|�\}}|r|rd||fS|rd|S|rd|SdS)Nr�z%s:z<unknown>:%sr)r��source�linerrrr<sr<cs(eZdZdejdef�fdd�Z�ZS)�ColorizeFormatterrdr.cs>t��|�}t|dd�}|durt�|j�}|rt||�S|S)NrV)rA�formatr:�	COLOR_MAP�getr\r)rCrdrDrVrErrr�s
zColorizeFormatter.format)rGrHrIrrhrLr�rMrrrErr�s r�c@s>eZdZdZdeddfdd�Zdeddfdd	�Zdd
d�ZdS)
�SafeEncodingWriterz7Stream writer which ignores UnicodeEncodeError silently�streamr.NcCs||_t|dd�p
d|_dS)N�encoding�ascii)r�r:r�)rCr�rrrrs#szSafeEncodingWriter.__init__�datac	CsFz	|j�|�WdSty"|j�|�|jd��|j��YdSw)N�replace)r��write�UnicodeEncodeError�encoder��decode�rCr�rrrr�'s
$�zSafeEncodingWriter.writecCst|jd�r
|j��dSdS)Nrv)�hasattrr�rvrtrrrrv/s�zSafeEncodingWriter.flushry)	rGrHrIrJrrsrLr�rvrrrrr�!s
r�c@s8eZdZdZdddeddfdd�Zd	eddfd
d�ZdS)�LastMessagesWriterzBStream writer storing last 10 messages in memory to save trackbackr�rr�r.NcCs
||_dSr)r�)rCr�r�rrrrs6r�zLastMessagesWriter.__init__r�cCs|jj�|�dSr)r��
messagelogrr�rrrr�9szLastMessagesWriter.write)rGrHrIrJrrsrLr�rrrrr�4sr�r�r�status�warningcCs0t�t�}|�tj�d|_|jdd�D]}|�|�qtt	|��}|�
t��|�
t|��|�t
|j�|�t��tt	|��}|�
t|��|�
t|��|�
t|��|�
t��|�tj�|�t��t�t||��}|�
t��|�t
|j�|�t��|�|�|�|�|�|�dS)zSetup root logger for SphinxFN)rr1r2r|r#�	propagater}r~rjr�r�r�r�r&�	verbosity�setFormatterr�rir�r�r�r�r�
StreamHandlerr�r�)r�r�r�r4r��info_handlerr��messagelog_handlerrrr�setup=s0


r�)T)SrJr�logging.handlers�collectionsr�
contextlibr�typingrrrrrr	r
rrr
�docutilsr�docutils.nodesr�docutils.utilsr�
sphinx.errorsr�sphinx.util.consoler�sphinx.applicationrr2r"rrLrZrK�updaterr rr!r#r&r�r1rhr>r?rOrR�
LoggerAdapterr/r�rirjr}�BufferingHandlerrp�Handlerr�r�r�rzr�r�r��Filterr�r�r�r�r�r�r�r�r�r�r<�	Formatterr�r�r�r�rrrr�<module>s�
0�
���-

"