
    ,hA                        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y)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        |    |  y t        | !  | j                         y N )	_check_params_check_kwargskwargsstrr   dict__doc__super__init__selfargsr   	__class__s      O/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/dns/exception.pyr   zDNSException.__init__7   s|    D+F+,$,,6v6DK4yDH&DK88||DHGd#GTXX&    c                 J    |s|rt        |      t        |      k7  sJ d       yy)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   s8     6:"  ONO  r   c                 ~    |r:t        |j                               | 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   sB    FKKM"d&6&66P<T=M=M<NOP r   c                     i }|j                         D ]e  \  }}t        |t        t        f      rEt        t	        t
        |            ||<   t        ||         dk(  sJ||   j                         ||<   a|||<   g |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   sy      	#HB$s,"3sD>2wr{#q(")"+//"3GBK"	# r   c                     | j                   rD| j                  r8 | 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   sP    ;;488&d&&55G"488??-W-- 7?$$r   )__name__
__module____qualname__r   r   r   r   __annotations__r   r   r   r	   r   r   r   r+   r.   __classcell__r   s   @r   r   r      sU    , C#EKS!C#' O$% %r   r   c                       e Zd ZdZy)	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y)SyntaxErrorzText input is malformed.Nr7   r   r   r   r9   r9   w       "r   r9   c                       e Zd ZdZy)UnexpectedEndzText input ended unexpectedly.Nr7   r   r   r   r<   r<   {   s    (r   r<   c                       e Zd ZdZy)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        |   |i | y 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@      s    &+K
CC* *r   r@   c                       e Zd ZdZy)UnsupportedAlgorithmz&The DNSSEC algorithm is not supported.Nr7   r   r   r   rE   rE      s    0r   rE   c                       e Zd ZdZy)AlgorithmKeyMismatchz=The DNSSEC algorithm is not supported for the given key type.Nr7   r   r   r   rG   rG      s    Gr   rG   c                       e Zd ZdZy)ValidationFailurez The DNSSEC signature is invalid.Nr7   r   r   r   rI   rI      s    *r   rI   c                       e Zd ZdZy)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y)ExceptionWrapperc                     || _         y 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                 j    |1t        || j                        s| j                  t        |            |y)NF)r#   rO   r   )r   exc_typeexc_valexc_tbs       r   __exit__zExceptionWrapper.__exit__   s1    
7D<P<P(Q&&s7|4'Ar   N)r/   r0   r1   r   rQ   rV   r   r   r   rM   rM      s    /r   rM   N)r   typingr   r   	Exceptionr   r6   r9   r<   r>   r@   rE   rG   rI   rK   rM   r   r   r   <module>rY      s   $ !T%9 T%n$ $#, #)K )&\ &	*l 	*1< 1H/ H+ +#\ #
 
r   