Viewing File: /opt/hc_python/lib/python3.12/site-packages/importlib_metadata/__pycache__/_context.cpython-312.pyc

�

`�*jp
��4�ddlmZddlZddlZGd�d�Zy)�)�annotationsNc�t�eZdZdZdZeffd�Zd�Zed��Z	ed��Z
ed��Zd�Zd	�Z
ed
�d�Zd�Zy
)�
ExceptionTrapa�
    A context manager that will catch certain exceptions and provide an
    indication they occurred.

    >>> with ExceptionTrap() as trap:
    ...     raise Exception()
    >>> bool(trap)
    True

    >>> with ExceptionTrap() as trap:
    ...     pass
    >>> bool(trap)
    False

    >>> with ExceptionTrap(ValueError) as trap:
    ...     raise ValueError("1 + 1 is not 3")
    >>> bool(trap)
    True
    >>> trap.value
    ValueError('1 + 1 is not 3')
    >>> trap.tb
    <traceback object at ...>

    >>> with ExceptionTrap(ValueError) as trap:
    ...     raise Exception()
    Traceback (most recent call last):
    ...
    Exception

    >>> bool(trap)
    False
    )NNNc��||_y�N)�
exceptions)�selfrs  �J/opt/hc_python/lib/python3.12/site-packages/importlib_metadata/_context.py�__init__zExceptionTrap.__init__,s	��$���c��|Sr��r	s r
�	__enter__zExceptionTrap.__enter__/s���rc� �|jdS�Nr��exc_infors r
�typezExceptionTrap.type2����}�}�Q��rc� �|jdS)N�rrs r
�valuezExceptionTrap.value6rrc� �|jdS)N�rrs r
�tbzExceptionTrap.tb:rrc�V�|d}|xrt||j�}|r||_|Sr)�
issubclassrr)r	rr�matchess    r
�__exit__zExceptionTrap.__exit__>s/����{���<�:�d�D�O�O�<���$�D�M��rc�,�t|j�Sr)�boolrrs r
�__bool__zExceptionTrap.__bool__Es���D�I�I��r��_testc�J����tj�����fd��}|S)a�
        Wrap func and replace the result with the truth
        value of the trap (True if an exception occurred).

        First, give the decorator an alias to support Python 3.8
        Syntax.

        >>> raises = ExceptionTrap(ValueError).raises

        Now decorate a function that always fails.

        >>> @raises
        ... def fail():
        ...     raise ValueError('failed')
        >>> fail()
        True
        c�x��t�j�5}�|i|��ddd���S#1swY�xYwr)rr)�args�kwargs�trapr%�funcr	s   ���r
�wrapperz%ExceptionTrap.raises.<locals>.wrapper[s6����t���/�4��d�%�f�%�0���;��0�/�s�	0�9)�	functools�wraps)r	r+r%r,s``` r
�raiseszExceptionTrap.raisesHs'���&
����	�	�
�	�
�rc�D�|j|tj��S)a�
        Wrap func and replace the result with the truth
        value of the trap (True if no exception).

        First, give the decorator an alias to support Python 3.8
        Syntax.

        >>> passes = ExceptionTrap(ValueError).passes

        Now decorate a function that always fails.

        >>> @passes
        ... def fail():
        ...     raise ValueError('failed')

        >>> fail()
        False
        r$)r/�operator�not_)r	r+s  r
�passeszExceptionTrap.passescs��&�{�{�4�x�}�}�{�5�5rN)�__name__�
__module__�__qualname__�__doc__r�	Exceptionrr�propertyrrrr r#r"r/r3rrr
rrss���B �H�#,�,�%��� �� �� �� �� �� ���%)��66rr)�
__future__rr-r1rrrr
�<module>r;s��"���n6�n6r
Back to Directory File Manager