
    i0                     H   d Z ddlmZ  G d de          Z G d de          Z G d de          Z G d	 d
e          Z G d de          Z G d de          Z	 G d de          Z
 G d de
          Z G d de          Z G d de          Z G d d          ZdS )zCommon DNS Exceptions.

Dnspython modules may also define their own exceptions, which will
always be subclasses of ``DNSException``.
    )Setc                        e Zd ZU dZdZedz  ed<    e            Ze	e         ed<   dZ
edz  ed<    fdZd Zd Zd	 Z fd
Z xZS )DNSExceptiona  Abstract base class shared by all dnspython exceptions.

    It supports two basic modes of operation:

    a) Old/compatible mode is used if ``__init__`` was called with
    empty *kwargs*.  In compatible mode all *args* are passed
    to the standard Python Exception class as before and all *args* are
    printed by the standard ``__str__`` implementation.  Class variable
    ``msg`` (or doc string if ``msg`` is ``None``) is returned from ``str()``
    if *args* is empty.

    b) New/parametrized mode is used if ``__init__`` was called with
    non-empty *kwargs*.
    In the new mode *args* must be empty and all kwargs must match
    those set in class variable ``supp_kwargs``. All kwargs are stored inside
    ``self.kwargs`` and used in a new ``__str__`` implementation to construct
    a formatted message based on the ``fmt`` class variable, a ``string``.

    In the simplest case it is enough to override the ``supp_kwargs``
    and ``fmt`` class variables to get nice parametrized messages.
    Nmsgsupp_kwargsfmtc                 @    | j         |i | |r' | j        di || _        t          |           | _        nt                      | _        | j        | j        | _        |r t                      j        |  d S t                                          | j                   d S N )	_check_params_check_kwargskwargsstrr   dict__doc__super__init__selfargsr   	__class__s      ]/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/dns/exception.pyr   zDNSException.__init__7   s    D+F+++ 	!,$,66v66DK4yyDHH&&DK8|DH 	'EGGd####GGTX&&&&&    c                 f    |s|r,t          |          t          |          k    s
J d            dS dS )zsOld exceptions supported only args and not kwargs.

        For sanity we do not allow to mix old and new behavior.z=keyword arguments are mutually exclusive with positional argsN)bool)r   r   r   s      r   r   zDNSException._check_paramsG   sd      	O6 	O::" "   N    	O 	Or   c                     |r<t          |                                          | j        k    sJ d| j                     |S )Nz+following set of keyword args is required: )setkeysr   )r   r   s     r   r   zDNSException._check_kwargsP   sJ     	PFKKMM""d&6666OT=MOO 766r   c                 :   i }|                                 D ]\  }}t          |t          t          z            r\t          t	          t
          |                    ||<   t          ||                   dk    r||                                         ||<   ~|||<   |S )zFormat kwargs before printing them.

        Resulting dictionary has to have keys necessary for str.format call
        on fmt class variable.
           )items
isinstancelistr   mapr   lenpop)r   r   fmtargskwdatas        r   _fmt_kwargszDNSException._fmt_kwargsW   s      	# 	#HB$s
++ #"3sD>>22wr{##q((")"+//"3"3GBK"r   c                     | j         r+| j        r$ | j        di | j         } | j        j        di |S t	                                                      S r
   )r   r   r*   formatr   __str__)r   r'   r   s     r   r-   zDNSException.__str__i   s`    ; 	%48 	%&d&5555G"48?--W--- 77??$$$r   )__name__
__module____qualname__r   r   r   __annotations__r   r   r   r   r   r   r   r*   r-   __classcell__r   s   @r   r   r      s          , CtCEEKS!!!Ct' ' ' ' ' O O O    $% % % % % % % % %r   r   c                       e Zd ZdZdS )	FormErrorzDNS message is malformed.Nr.   r/   r0   r   r   r   r   r5   r5   s   s        ####r   r5   c                       e Zd ZdZdS )SyntaxErrorzText input is malformed.Nr6   r   r   r   r8   r8   w           """"r   r8   c                       e Zd ZdZdS )UnexpectedEndzText input ended unexpectedly.Nr6   r   r   r   r;   r;   {   s        ((((r   r;   c                       e Zd ZdZdS )TooBigzThe DNS message is too big.Nr6   r   r   r   r=   r=      s        %%%%r   r=   c                   ,     e Zd ZdZdhZdZ fdZ xZS )TimeoutzThe DNS operation timed out.timeoutz7The DNS operation timed out after {timeout:.3f} secondsc                 :     t                      j        |i | d S N)r   r   r   s      r   r   zTimeout.__init__   s%    $)&)))))r   )r.   r/   r0   r   r   r   r   r2   r3   s   @r   r?   r?      sJ        &&+K
CC* * * * * * * * *r   r?   c                       e Zd ZdZdS )UnsupportedAlgorithmz&The DNSSEC algorithm is not supported.Nr6   r   r   r   rD   rD      s        0000r   rD   c                       e Zd ZdZdS )AlgorithmKeyMismatchz=The DNSSEC algorithm is not supported for the given key type.Nr6   r   r   r   rF   rF      s        GGGGr   rF   c                       e Zd ZdZdS )ValidationFailurez The DNSSEC signature is invalid.Nr6   r   r   r   rH   rH      s        ****r   rH   c                       e Zd ZdZdS )DeniedByPolicyzDenied by DNSSEC policy.Nr6   r   r   r   rJ   rJ      r9   r   rJ   c                        e Zd Zd Zd Zd ZdS )ExceptionWrapperc                     || _         d S rB   )exception_class)r   rN   s     r   r   zExceptionWrapper.__init__   s    .r   c                     | S rB   r   )r   s    r   	__enter__zExceptionWrapper.__enter__   s    r   c                 z    |8t          || j                  s#|                     t          |                    |dS )NF)r"   rN   r   )r   exc_typeexc_valexc_tbs       r   __exit__zExceptionWrapper.__exit__   s;    
7D<P(Q(Q&&s7||44'Aur   N)r.   r/   r0   r   rP   rU   r   r   r   rL   rL      sA        / / /      r   rL   N)r   typingr   	Exceptionr   r5   r8   r;   r=   r?   rD   rF   rH   rJ   rL   r   r   r   <module>rX      s  $       T% T% T% T% T%9 T% T% T%n$ $ $ $ $ $ $ $# # # # #, # # #) ) ) ) )K ) ) )& & & & &\ & & &	* 	* 	* 	* 	*l 	* 	* 	*1 1 1 1 1< 1 1 1H H H H H/ H H H+ + + + + + + +# # # # #\ # # #
 
 
 
 
 
 
 
 
 
r   