PK APOCALYPSE V1

APOCALYPSE V1

Current Path : /opt/hc_python/lib/python3.12/site-packages/nose/plugins/__pycache__/
Upload File :
Current File : //opt/hc_python/lib/python3.12/site-packages/nose/plugins/__pycache__/logcapture.cpython-312.pyc

�

���g�$����dZddlZddlmZddlZddlmZddlmZmZm	Z		ddl
mZeje�ZGd�de�ZGd	�d
e�ZGd�de�Zy#e$r	ddl
mZY�AwxYw)
a
This plugin captures logging statements issued during test execution. When an
error or failure occurs, the captured log messages are attached to the running
test in the test.capturedLogging attribute, and displayed with the error failure
output. It is enabled by default but can be turned off with the option
``--nologcapture``.

You can filter captured logging statements with the ``--logging-filter`` option. 
If set, it specifies which logger(s) will be captured; loggers that do not match
will be passed. Example: specifying ``--logging-filter=sqlalchemy,myapp``
will ensure that only statements logged via sqlalchemy.engine, myapp
or myapp.foo.bar logger will be logged.

You can remove other installed logging handlers with the
``--logging-clear-handlers`` option.
�N)�Handler)�Plugin)�anyp�ln�safe_str)�StringIOc�P�eZdZd�Zd�Zee�Zd�Zd�Zee�Zd�Zd�Z	y)�	FilterSetc�@�|j|�\|_|_y�N)�
_partition�	inclusive�	exclusive)�self�filter_componentss  �F/opt/hc_python/lib/python3.12/site-packages/nose/plugins/logcapture.py�__init__zFilterSet.__init__!s��)-���9J�)K�&�����c��gg}}|D]9}|jd�r|j|dd��)|j|��;||fS)N�-�)�
startswith�append)�
componentsrr�	components    rr
zFilterSet._partition%sR��!�2�9�	�#�I��#�#�C�(�� � ��1�2��/�� � ��+�	$�
�)�#�#rc�R�|sy|j|�xr|j|�S)z-returns whether this record should be printedT)�_allow�_deny�r�records  r�allowzFilterSet.allow/s(�����{�{�6�"�=�4�:�:�f�+=�'=�=rc	�T���fd�}tttt||���S)zNreturn the bool of whether `record` starts with
        any item in `matchers`c�:���|k(xs�j|dz�S)N�.)r)�keyr s �r�record_matches_keyz0FilterSet._any_match.<locals>.record_matches_key:s!����S�=�@�F�$5�$5�c�C�i�$@�@r)r�bool�list�map)�matchersr r&s ` r�
_any_matchzFilterSet._any_match7s#���	A��D�$�s�#5�x�@�A�B�Brc�T�|jsy|j|j|�S)NT)rr+rs  rrzFilterSet._allow?s!���~�~�����t�~�~�v�6�6rc�T�|jsy|j|j|�S)NF)rr+rs  rrzFilterSet._denyDs!���~�~�����t�~�~�v�6�6rN)
�__name__�
__module__�__qualname__rr
�staticmethodr!r+rr�rrr
r
 s:��L�$��j�)�J�>�C��j�)�J�7�
7rr
c�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)	�MyMemoryHandlerc��tj|�tj||�}|j	|�t|�|_g|_yr)rr�logging�	Formatter�setFormatterr
�	filterset�buffer)r�	logformat�
logdatefmt�filters�fmts     rrzMyMemoryHandler.__init__KsC����������	�:�6�����#��"�7�+�����rc�X�|jj|j|��yr)r:r�formatrs  r�emitzMyMemoryHandler.emitQs�������4�;�;�v�.�/rc��yrr2�rs r�flushzMyMemoryHandler.flushS���rc��g|_yr)r:rCs r�truncatezMyMemoryHandler.truncateUs	����rc�z�|jj|j�rtj||�Syr)r9r!�namer�filterrs  rrJzMyMemoryHandler.filterWs.���>�>������,��>�>�$��/�/�-rc�@�|jj�}|d=|S)N�lock)�__dict__�copy�r�states  r�__getstate__zMyMemoryHandler.__getstate__Zs ���
�
�"�"�$���&�M��rc�l�|jj|�tj�|_yr)rM�update�	threading�RLockrLrOs  r�__setstate__zMyMemoryHandler.__setstate__^s"���
�
���U�#��O�O�%��	rN)
r.r/r0rrArDrGrJrQrVr2rrr4r4Js%���0�
��0��&rr4c�z�eZdZdZdZdZdZdZdZdZ	dZ
d	gZd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�
LogCapturea
    Log capture plugin. Enabled by default. Disable with --nologcapture.
    This plugin captures logging statements issued during test execution,
    appending any output captured to the error or failure output,
    should the test fail or raise an error.
    T�NOSE_NOLOGCAPTURE�
logcapturei�z$%(name)s: %(levelname)s: %(message)sNFz-nosec���|jdd|j|j�dd��|jddd|jd	�xs|jd
d��|jd
dd|jd�xs|jd
d��|jddd|jd�dd��|jddddd��|jddddd��y) z&Register commandline options.
        z--nologcapture�store_falserZz^Disable logging capture plugin. Logging configuration will be left intact. [NOSE_NOLOGCAPTURE])�action�default�dest�helpz--logging-format�store�logcapture_format�NOSE_LOGFORMAT�FORMATzvSpecify custom format to print statements. Uses the same format as used by standard logging handlers. [NOSE_LOGFORMAT])r]r_r^�metavarr`z--logging-datefmt�logcapture_datefmt�NOSE_LOGDATEFMTz�Specify custom date/time format to print statements. Uses the same format as used by standard logging handlers. [NOSE_LOGDATEFMT]z--logging-filter�logcapture_filters�NOSE_LOGFILTER�FILTERa�Specify which statements to filter in/out. By default, everything is captured. If the output is too verbose,
use this option to filter out needless output.
Example: filter=foo will capture statements issued ONLY to
 foo or foo.what.ever.sub but not foobar or other logger.
Specify multiple loggers with comma: filter=foo,bar,baz.
If any logger name is prefixed with a minus, eg filter=-foo,
it will be excluded rather than included. Default: exclude logging messages from nose itself (-nose). [NOSE_LOGFILTER]
z--logging-clear-handlers�
store_trueF�logcapture_clearz Clear all other logging handlersz--logging-level�NOTSET�logcapture_levelzSet the log level to captureN)�
add_option�get�env_optr;r<)r�parser�envs   r�optionszLogCapture.optionsss$��	����]�������-�-�L�(�	�	)�	����w�5H��G�G�,�-�?�����%�		�	&�	�����6J��G�G�-�.�A�$�/�/��&�		�	'�	����w�5I��G�G�,�-��	'�		�
	(�	���&�|�� 2�3�	�	5�	����g��#5�/�	�	1rc�2�||_|jr|jrd|_|j|_|j|_|j|_	|j|_|jr!|jjd�|_yy)zConfigure plugin.
        F�,N)�confrZ�
loggingConfig�enabledrbr;rfr<rl�clearrn�loglevelrh�splitr=)rrtrws   r�	configurezLogCapture.configure�s����	��!�!�T�%7�%7� �D�L� �2�2���!�4�4����-�-��
��0�0��
��%�%�"�5�5�;�;�C�@�D�L�&rc��tj�}|jr�t|d�r"|jD]}|j|��t
tjjjj��D]1}t|d�s�|jD]}|j|���3|jddD].}t|t�s�|jj|��0|j|j�t!|dd�}|j#t!t|��y)N�handlersr{rm)r6�	getLoggerrz�hasattrr�
removeHandlerr(�Logger�manager�
loggerDict�values�
isinstancer4�remove�
addHandler�handler�getattr�setLevel)r�root_loggerr��loggerr{s     r�setupLoghandlerzLogCapture.setupLoghandler�s����'�'�)���:�:��{�J�/�*�3�3�G��-�-�g�6� 4��w�~�~�5�5�@�@�G�G�I�J���6�:�.�#)�?�?���,�,�W�5�$3�K�#�+�+�A�.�G��'�?�3��$�$�+�+�G�4�/�	���t�|�|�,��4��X�6�����W�W�h�7�8rc�$�|j�y)z7Set up logging handler before test run begins.
        N)�startrCs r�beginzLogCapture.begin�s
��	
�
�
�rc��t|j|j|j�|_|j�yr)r4r;r<r=r�r�rCs rr�zLogCapture.start�s-��&�t�~�~�t���'+�|�|�5������rc��yrr2rCs r�endzLogCapture.end�rErc�$�|j�y)z0Clear buffers and handlers before test.
        N)r��r�tests  r�
beforeTestzLogCapture.beforeTest�s��	
���rc�8�|jj�y)z"Clear buffers after test.
        N)r�rGr�s  r�	afterTestzLogCapture.afterTest�s��	
�����rc�&�|j||�S)z5Add captured log messages to failure output.
        )�formatError)rr��errs   r�
formatFailurezLogCapture.formatFailure�s������c�*�*rc�n�|j�x|_}|s|S|\}}}||j||�|fS)z3Add captured log messages to error output.
        )�formatLogRecords�capturedLogging�addCaptureToErr)rr�r��records�ec�ev�tbs       rr�zLogCapture.formatError�sG��*.�)>�)>�)@�@���w���J��
��B���D�(�(��W�5�r�:�:rc�\�ttt|jj��Sr)r(r)rr�r:rCs rr�zLogCapture.formatLogRecords�s���C��$�,�,�"5�"5�6�7�7rc�l�djt|�td�g|ztd�gz�S)N�
z>> begin captured logging <<z>> end captured logging <<)�joinrr)rr�r�s   rr�zLogCapture.addCaptureToErr�s=���y�y�(�2�,��+I�(J�K�!�"��:�;�<�=�>�	>r)r.r/r0�__doc__ryrqrI�scorer;r<rzr=rtr}r�r�r�r�r�r�r�r�r�r�r2rrrXrXcsq����G�!�G��D��E�6�I��J��E��i�G�,1�\
A�9�2�
�

��
 �
+�
;�8�>rrX)r�r6rrT�nose.plugins.baser�	nose.utilrrr�ior�ImportErrorr�r.�log�objectr
r4rXr2rr�<module>r�sv���"���$�(�(����g����!��'7��'7�T&�g�&�2R>��R>��Q����s�A�A*�)A*

if you don't want to be vaporized in a nuclear explosion, i simply have to become nuclear myself… i am atomic