
    
3jp
                    4    S SK Jr  S SKrS SKr " S S5      rg)    )annotationsNc                      \ rS rSrSrSr\44S jrS r\	S 5       r
\	S 5       r\	S 5       rS	 rS
 r\S.S jrS rSrg)ExceptionTrap   aA  
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                    Xl         g N)
exceptions)selfr	   s     U/home/wildlama/miniconda3/lib/python3.13/site-packages/importlib_metadata/_context.py__init__ExceptionTrap.__init__,   s    $    c                    U $ r    r
   s    r   	__enter__ExceptionTrap.__enter__/   s    r   c                     U R                   S   $ Nr   exc_infor   s    r   typeExceptionTrap.type2       }}Qr   c                     U R                   S   $ )N   r   r   s    r   valueExceptionTrap.value6   r   r   c                     U R                   S   $ )N   r   r   s    r   tbExceptionTrap.tb:   r   r   c                f    US   nU=(       a    [        X R                  5      nU(       a  Xl        U$ r   )
issubclassr	   r   )r
   r   r   matchess       r   __exit__ExceptionTrap.__exit__>   s+    {<:dOO<$Mr   c                ,    [        U R                  5      $ r   )boolr   r   s    r   __bool__ExceptionTrap.__bool__E   s    DIIr   _testc               N   ^ ^^ [         R                  " T5      UUU 4S j5       nU$ )aQ  
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                    > [        TR                  5       nT" U 0 UD6  S S S 5        T" W5      $ ! , (       d  f       N= fr   )r   r	   )argskwargstrapr-   funcr
   s      r   wrapper%ExceptionTrap.raises.<locals>.wrapper[   s6    t/4d%f% 0; 0/s   	0
>)	functoolswraps)r
   r3   r-   r4   s   ``` r   raisesExceptionTrap.raisesH   s'    & 
		 
	
 r   c                >    U R                  U[        R                  S9$ )aJ  
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,   )r8   operatornot_)r
   r3   s     r   passesExceptionTrap.passesc   s    & {{4x}}{55r   )r   r	   N)__name__
__module____qualname____firstlineno____doc__r   	Exceptionr   r   propertyr   r   r!   r&   r*   r)   r8   r=   __static_attributes__r   r   r   r   r      ss    B  H#,, %             %) 66r   r   )
__future__r   r6   r;   r   r   r   r   <module>rH      s    "  n6 n6r   