
                             S 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``.
c                   `   ^  \ rS rSrSrSr\" 5       rSr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.
Nc                 N  > 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  [        [        U ]&  " U6   g [        [        U ]'  U R                  5        g N )
_check_params_check_kwargskwargsstrmsgdict__doc__superr   __init__)selfargsr
   	__class__s       lib/third_party/dns/exception.pyr   DNSException.__init__3   s|    D+F+,,6v6DK4yDH&DK88||DH,.5,.txx8    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_paramsB   s0     6:f- POP- r   c                     U(       a;  [        UR                  5       5      U R                  :X  d   SU R                  -  5       eU$ )Nz-following set of keyword args is required: %s)setkeyssupp_kwargs)r   r
   s     r   r	   DNSException._check_kwargsJ   sC    v{{}%)9)99 &?$$&&9 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_kwargsQ   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$ [        [
        U ]  5       $ r   )r
   fmtr*   formatr   r   __str__)r   r'   r   s     r   r/   DNSException.__str__c   sO    ;;488&&55G88??-W-- t466r   )r
   r   )__name__
__module____qualname____firstlineno__r   r   r   r   r-   r   r   r	   r*   r/   __static_attributes____classcell__)r   s   @r   r   r      s:    , C%K
C9P$7 7r   r   c                       \ rS rSrSrSrg)	FormErrorm   zDNS message is malformed.r   Nr1   r2   r3   r4   r   r5   r   r   r   r8   r8   m   s    #r   r8   c                       \ rS rSrSrSrg)SyntaxErrorq   zText input is malformed.r   Nr:   r   r   r   r<   r<   q   s    "r   r<   c                       \ rS rSrSrSrg)UnexpectedEndu   zText input ended unexpectedly.r   Nr:   r   r   r   r?   r?   u   s    (r   r?   c                       \ rS rSrSrSrg)TooBigy   zThe DNS message is too big.r   Nr:   r   r   r   rB   rB   y   s    %r   rB   c                   "    \ rS rSrSrS1rSrSrg)Timeout}   zThe DNS operation timed out.timeoutz3The DNS operation timed out after {timeout} secondsr   N)r1   r2   r3   r4   r   r   r-   r5   r   r   r   rE   rE   }   s    &+K
?Cr   rE   N)r   	Exceptionr   r8   r<   r?   rB   rE   r   r   r   <module>rI      sW   $R79 R7j$ $#, #)K )&\ &@l @r   