
    EqgA                     L   d Z ddlmZ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``.
    )OptionalSetc                        e Zd ZU dZdZee         ed<    e            Z	e
e         ed<   dZee         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/env/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                 8   i }|                                 D ]\  }}t          |t          t          f          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   r   __annotations__r   r   r   r	   r   r   r   r+   r.   __classcell__r   s   @r   r   r      s          , C#CEEKS!!!C#' ' ' ' ' O O O    $% % % % % % % % %r   r   c                       e Zd ZdZdS )	FormErrorzDNS message is malformed.Nr/   r0   r1   r   r   r   r   r6   r6   s   s        ####r   r6   c                       e Zd ZdZdS )SyntaxErrorzText input is malformed.Nr7   r   r   r   r9   r9   w           """"r   r9   c                       e Zd ZdZdS )UnexpectedEndzText input ended unexpectedly.Nr7   r   r   r   r<   r<   {   s        ((((r   r<   c                       e Zd ZdZdS )TooBigzThe DNS message is too big.Nr7   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/   r0   r1   r   r   r	   r   r3   r4   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.Nr7   r   r   r   rE   rE      s        0000r   rE   c                       e Zd ZdZdS )AlgorithmKeyMismatchz=The DNSSEC algorithm is not supported for the given key type.Nr7   r   r   r   rG   rG      s        GGGGr   rG   c                       e Zd ZdZdS )ValidationFailurez The DNSSEC signature is invalid.Nr7   r   r   r   rI   rI      s        ****r   rI   c                       e Zd ZdZdS )DeniedByPolicyzDenied by DNSSEC policy.Nr7   r   r   r   rK   rK      r:   r   rK   c                        e Zd Zd Zd Zd ZdS )ExceptionWrapperc                     || _         d S rC   )exception_class)r   rO   s     r   r   zExceptionWrapper.__init__   s    .r   c                     | S rC   r   )r   s    r   	__enter__zExceptionWrapper.__enter__   s    r   c                 z    |8t          || j                  s#|                     t          |                    |dS )NF)r#   rO   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/   r0   r1   r   rQ   rV   r   r   r   rM   rM      sA        / / /      r   rM   N)r   typingr   r   	Exceptionr   r6   r9   r<   r>   r@   rE   rG   rI   rK   rM   r   r   r   <module>rY      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   