
    gA                        S r SSKJrJr   " S S\5      r " S S\5      r " S S\5      r " S	 S
\5      r " S S\5      r	 " S S\5      r
 " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S5      rg)zCommon DNS Exceptions.

Dnspython modules may also define their own exceptions, which will
always be subclasses of ``DNSException``.
    )OptionalSetc                      ^  \ rS rSr% SrSr\\   \S'   \	" 5       r
\\   \S'   Sr\\   \S'   U 4S jrS rS	 rS
 rU 4S jrSrU =r$ )DNSException   a  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                 >  > U R                   " U0 UD6  U(       a(  U R                  " S0 UD6U l        [        U 5      U l        O[        5       U l        U R                  c  U R                  U l        U(       a  [        TU ]   " U6   g [        TU ]!  U R                  5        g N )	_check_params_check_kwargskwargsstrr   dict__doc__super__init__selfargsr   	__class__s      F/home/matz/Project1/venv/lib/python3.13/site-packages/dns/exception.pyr   DNSException.__init__7   sx    D+F+,,6v6DK4yDH&DK88||DHGd#GTXX&    c                 `    U(       d  U(       a   [        U5      [        U5      :w  d   S5       egg)zkOld 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   DNSException._check_paramsG   s8     6:"  ONO  r   c                     U(       a;  [        UR                  5       5      U R                  :X  d   SU R                   35       eU$ )Nz+following set of keyword args is required: )setkeysr	   )r   r   s     r   r   DNSException._check_kwargsP   sC    FKKM"d&6&66P<T=M=M<NOP6r   c                    0 nUR                  5        Hh  u  p4[        U[        [        45      (       aD  [        [	        [
        U5      5      X#'   [        X#   5      S:X  a  X#   R                  5       X#'   Mb  Md  XBU'   Mj     U$ )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_kwargsDNSException._fmt_kwargsW   sr     HB$s,,"3sD>2w{#q(")+//"3GK ) # ' r   c                    > U R                   (       aI  U R                  (       a8  U R                  " S0 U R                   D6nU R                  R                  " S0 UD6$ [        TU ]  5       $ r   )r   r
   r/   formatr   __str__)r   r,   r   s     r   r3   DNSException.__str__i   sL    ;;488&&55G88??-W-- 7?$$r   )r   r   )__name__
__module____qualname____firstlineno__r   r   r   r   __annotations__r!   r	   r   r
   r   r   r   r/   r3   __static_attributes____classcell__r   s   @r   r   r      sU    , C#EKS!C#' O$% %r   r   c                       \ rS rSrSrSrg)	FormErrors   zDNS message is malformed.r   Nr5   r6   r7   r8   r   r:   r   r   r   r>   r>   s   s    #r   r>   c                       \ rS rSrSrSrg)SyntaxErrorw   zText input is malformed.r   Nr@   r   r   r   rB   rB   w       "r   rB   c                       \ rS rSrSrSrg)UnexpectedEnd{   zText input ended unexpectedly.r   Nr@   r   r   r   rF   rF   {   s    (r   rF   c                       \ rS rSrSrSrg)TooBig   zThe DNS message is too big.r   Nr@   r   r   r   rI   rI      s    %r   rI   c                   6   ^  \ rS rSrSrS1rSrU 4S jrSrU =r	$ )Timeout   zThe DNS operation timed out.timeoutz7The DNS operation timed out after {timeout:.3f} secondsc                 &   > [         TU ]  " U0 UD6  g N)r   r   r   s      r   r   Timeout.__init__   s    $)&)r   r   )
r5   r6   r7   r8   r   r	   r
   r   r:   r;   r<   s   @r   rL   rL      s    &+K
CC* *r   rL   c                       \ rS rSrSrSrg)UnsupportedAlgorithm   z&The DNSSEC algorithm is not supported.r   Nr@   r   r   r   rS   rS      s    0r   rS   c                       \ rS rSrSrSrg)AlgorithmKeyMismatch   z=The DNSSEC algorithm is not supported for the given key type.r   Nr@   r   r   r   rV   rV      s    Gr   rV   c                       \ rS rSrSrSrg)ValidationFailure   z The DNSSEC signature is invalid.r   Nr@   r   r   r   rY   rY      s    *r   rY   c                       \ rS rSrSrSrg)DeniedByPolicy   zDenied by DNSSEC policy.r   Nr@   r   r   r   r\   r\      rD   r   r\   c                   &    \ rS rSrS rS rS rSrg)ExceptionWrapper   c                     Xl         g rP   exception_class)r   rc   s     r   r   ExceptionWrapper.__init__   s    .r   c                     U $ rP   r   )r   s    r   	__enter__ExceptionWrapper.__enter__   s    r   c                 t    Ub5  [        X R                  5      (       d  U R                  [        U5      5      Ueg)NF)r'   rc   r   )r   exc_typeexc_valexc_tbs       r   __exit__ExceptionWrapper.__exit__   s2    
7<P<P(Q(Q&&s7|4'Ar   rb   N)r5   r6   r7   r8   r   rf   rl   r:   r   r   r   r_   r_      s    /r   r_   N)r   typingr   r   	Exceptionr   r>   rB   rF   rI   rL   rS   rV   rY   r\   r_   r   r   r   <module>rp      s   $ !T%9 T%n$ $#, #)K )&\ &	*l 	*1< 1H/ H+ +#\ #
 
r   