
    !jp
                    <    d dl mZ d dlZd dlZ G d d          ZdS )    )annotationsNc                      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dS )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                    || _         d S N)
exceptions)selfr   s     W/var/www/html/bolsaweb/venv/lib/python3.11/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         }|ot          || j                  }|r|| _        |S r   )
issubclassr   r   )r	   r   r   matchess       r
   __exit__zExceptionTrap.__exit__>   s5    {<:dDO<< 	%$DMr   c                *    t          | j                  S r   )boolr   r   s    r
   __bool__zExceptionTrap.__bool__E   s    DIr   _testc               N     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                     t          j                  5 } | i | d d d            n# 1 swxY w Y    |          S r   )r   r   )argskwargstrapr%   funcr	   s      r
   wrapperz%ExceptionTrap.raises.<locals>.wrapper[   s    t// &4d%f%%%& & & & & & & & & & & & & & &5;;s   	+//)	functoolswraps)r	   r+   r%   r,   s   ``` r
   raiseszExceptionTrap.raisesH   sF    & 
			 	 	 	 	 	 
		
 r   c                D    |                      |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55r   N)__name__
__module____qualname____doc__r   	Exceptionr   r   propertyr   r   r   r    r#   r"   r/   r3   r   r   r
   r   r      s         B  H#,, % % % %       X      X      X      %)     66 6 6 6 6r   r   )
__future__r   r-   r1   r   r   r   r
   <module>r;      sh    " " " " " "     n6 n6 n6 n6 n6 n6 n6 n6 n6 n6r   