
    jp
                    4    d dl mZ d dlZd dlZ G d d      Zy)    )annotationsNc                  t    e Zd ZdZdZeffdZd Zed        Z	ed        Z
ed        Zd Zd	 Zed
dZd Zy)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)selfr   s     t/Users/manta/Documents/Projects/TheRoad-I1/backend/.venv/lib/python3.12/site-packages/importlib_metadata/_context.py__init__zExceptionTrap.__init__,   s	    $    c                    | S r    r	   s    r
   	__enter__zExceptionTrap.__enter__/   s    r   c                     | j                   d   S Nr   exc_infor   s    r
   typezExceptionTrap.type2       }}Qr   c                     | j                   d   S )N   r   r   s    r
   valuezExceptionTrap.value6   r   r   c                     | j                   d   S )N   r   r   s    r
   tbzExceptionTrap.tb:   r   r   c                V    |d   }|xr t        || j                        }|r|| _        |S r   )
issubclassr   r   )r	   r   r   matchess       r
   __exit__zExceptionTrap.__exit__>   s/    {<:dDOO<$DMr   c                ,    t        | j                        S r   )boolr   r   s    r
   __bool__zExceptionTrap.__bool__E   s    DIIr   _testc               J     t        j                         fd       }|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 | d d d               S # 1 sw Y   xY wr   )r   r   )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
   raiseszExceptionTrap.raisesH   s'    & 
		 
	
 r   c                D    | j                  |t        j                        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
   passeszExceptionTrap.passesc   s    & {{4x}}{55r   N)__name__
__module____qualname____doc__r   	Exceptionr   r   propertyr   r   r   r    r#   r"   r/   r3   r   r   r
   r   r      ss    B  H#,, %             %) 66r   r   )
__future__r   r-   r1   r   r   r   r
   <module>r;      s    "  n6 n6r   