fEdZddlmZmZGddeZGddeZGddeZGd d eZGd d eZ Gd deZ GddeZ Gdde Z GddeZ GddeZGddZy)zCommon DNS Exceptions. Dnspython modules may also define their own exceptions, which will always be subclasses of ``DNSException``. )OptionalSetceZdZUdZdZeeed<eZ e eed<dZ eeed<fdZ dZ dZd Zfd ZxZS) DNSExceptionaAbstract 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. Nmsg supp_kwargsfmtc&|j|i||r(|jdi||_t||_nt |_|j|j |_|r t| |yt|!|jyN) _check_params _check_kwargskwargsstrrdict__doc__super__init__selfargsr __class__s V/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dns/exception.pyrzDNSException.__init__7s|D+F+ ,$,,6v6DK4yDH&DK 88 ||DH  G d # G TXX &cJ|s|rt|t|k7sJdyy)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)rrrs rr zDNSException._check_paramsGs8 6:" ON Orc ~|r:t|j|jk(sJd|jz|S)Nz-following set of keyword args is required: %s)setkeysr)rrs rrzDNSException._check_kwargsPs@ FKKM"d&6&66 T>$BRBRS T6 rc i}|jD]e\}}t|ttfrEtt t |||<t ||dk(sJ||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 isinstancelistrmaprlenpop)rrfmtargskwdatas r _fmt_kwargszDNSException._fmt_kwargsWst  HB$s ,"3sD>2 wr{#q(")"+//"3GBK" 'rc|jrD|jr8|jdi|j}|jjdi|St|Sr )rr r+formatr__str__)rr(rs rr.zDNSException.__str__isP ;;488&d&&55G"488??-W- -7?$ $r)__name__ __module__ __qualname__rrrr__annotations__rrrr rr rr+r. __classcell__rs@rrrsU,C#EKS!C#' O$%%rrceZdZdZy) FormErrorzDNS message is malformed.Nr/r0r1rr rrr6r6ss#rr6ceZdZdZy) SyntaxErrorzText input is malformed.Nr7r rrr9r9w"rr9ceZdZdZy) UnexpectedEndzText input ended unexpectedly.Nr7r rrr<r<{s(rr<ceZdZdZy)TooBigzThe DNS message is too big.Nr7r rrr>r>s%rr>c,eZdZdZdhZdZfdZxZS)TimeoutzThe DNS operation timed out.timeoutz7The DNS operation timed out after {timeout:.3f} secondsc$t||i|yN)rrrs rrzTimeout.__init__s $)&)r)r/r0r1rrr rr3r4s@rr@r@s&+K CC**rr@ceZdZdZy)UnsupportedAlgorithmz&The DNSSEC algorithm is not supported.Nr7r rrrErEs0rrEceZdZdZy)AlgorithmKeyMismatchz=The DNSSEC algorithm is not supported for the given key type.Nr7r rrrGrGsGrrGceZdZdZy)ValidationFailurez The DNSSEC signature is invalid.Nr7r rrrIrIs*rrIceZdZdZy)DeniedByPolicyzDenied by DNSSEC policy.Nr7r rrrKrKr:rrKceZdZdZdZdZy)ExceptionWrapperc||_yrC)exception_class)rrOs rrzExceptionWrapper.__init__s .rc|SrCr )rs r __enter__zExceptionWrapper.__enter__s rcj|1t||js|jt||y)NF)r#rOr)rexc_typeexc_valexc_tbs r__exit__zExceptionWrapper.__exit__s1   7Dr@rErGrIrKrMr rrrYs$!T%9T%n$ $#,#)K)&\& *l *1<1H/H+ +#\#  r