
    ui                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	rSSK
rSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKr " S S\R*                  R,                  5      r " S S\5      r " S S\5      r " S	 S
\5      r " S S\R*                  R,                  5      r " S S\R*                  R,                  5      r " S S\R*                  R,                  5      r " S S\R*                  R,                  5      r " S S\R>                  R@                  5      r! " S S\R>                  R@                  5      r"\"RF                  \RH                  \"RJ                  \RL                  0r' " S S\RP                  RR                  5      r* " S S\RP                  RV                  5      r+S\RX                  RZ                  S\*SSSS4S jr.S\RX                  RZ                  S\*SSS4S jr/\*SS4S jr0g) z
DNS Zones.    Nc                       \ rS rSrSrSrg)BadZone*   zThe DNS zone is malformed. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       ?/home/kodi/.kodi/addons/script.module.dnspython/lib/dns/zone.pyr   r   *   s    $r   r   c                       \ rS rSrSrSrg)NoSOA/   z)The DNS zone has no SOA RR at its origin.r   Nr   r   r   r   r   r   /   s    3r   r   c                       \ rS rSrSrSrg)NoNS4   z+The DNS zone has no NS RRset at its origin.r   Nr   r   r   r   r   r   4   s    5r   r   c                       \ rS rSrSrSrg)UnknownOrigin9   z!The DNS zone's origin is unknown.r   Nr   r   r   r   r   r   9   s    +r   r   c                       \ rS rSrSrSrg)UnsupportedDigestScheme>   z(The zone digest's scheme is unsupported.r   Nr   r   r   r   r   r   >       2r   r   c                       \ rS rSrSrSrg)UnsupportedDigestHashAlgorithmC   z(The zone digest's origin is unsupported.r   Nr   r   r   r   r   r   C   r   r   r   c                       \ rS rSrSrSrg)NoDigestH   z/The DNS zone has no ZONEMD RRset at its origin.r   Nr   r   r   r   r!   r!   H   s    9r   r!   c                       \ rS rSrSrSrg)DigestVerificationFailureM   z#The ZONEMD digest failed to verify.r   Nr   r   r   r   r$   r$   M   s    -r   r$   c                   ,    \ rS rSrSrSr\S 5       rSrg)DigestSchemeR   zZONEMD Scheme   c                     gN   r   clss    r   _maximumDigestScheme._maximumW       r   r   N)	r   r	   r
   r   r   SIMPLEclassmethodr/   r   r   r   r   r'   r'   R   s    F r   r'   c                   0    \ rS rSrSrSrSr\S 5       rSr	g)DigestHashAlgorithm\   zZONEMD Hash Algorithmr)      c                     gr+   r   r-   s    r   r/   DigestHashAlgorithm._maximumb   r1   r   r   N)
r   r	   r
   r   r   SHA384SHA512r3   r/   r   r   r   r   r5   r5   \   s!    FF r   r5   c                   6   \ rS rSrSr\R                  R                  r/ SQr	\R                  R                  S4S jrS rS rS rS	 rS
 rS rS rS rS rS rS rS rS*S jrS*S jrS r\R8                  R:                  S4S jr\R8                  R:                  S4S jr\R8                  R:                  4S jr S r!\R8                  R:                  4S jr"\R8                  R:                  4S jr#\R8                  RH                  \R8                  R:                  4S jr%\R8                  RH                  \R8                  R:                  4S jr&  S+S jr'  S+S  jr(S! r)\*RV                  4S" jr,\*RV                  4S# jr-S,S$ jr.S% r/S*S& jr0S' r1S( r2S)r3g)-Zonem   a^  A DNS zone.

A ``Zone`` is a mapping from names to nodes.  The zone object may be
treated like a Python dictionary, e.g. ``zone[name]`` will retrieve
the node associated with that name.  The *name* may be a
``dns.name.Name object``, or it may be a string.  In either case,
if the name is relative it is treated as relative to the origin of
the zone.
)rdclassoriginnodes
relativizeTc                 N   Ub  [        U[        5      (       a   [        R                  R	                  U5      nO4[        U[        R                  R
                  5      (       d  [        S5      eUR                  5       (       d  [        S5      eXl        X l	        0 U l
        X0l        g)a  Initialize a zone object.

*origin* is the origin of the zone.  It may be a ``dns.name.Name``,
a ``str``, or ``None``.  If ``None``, then the zone's origin will
be set by the first ``$ORIGIN`` line in a zone file.

*rdclass*, an ``int``, the zone's rdata class; the default is class IN.

*relativize*, a ``bool``, determine's whether domain names are
relativized to the zone's origin.  The default is ``True``.
Nz2origin parameter must be convertible to a DNS namez)origin parameter must be an absolute name)
isinstancestrdnsname	from_textName
ValueErroris_absoluter@   r?   rA   rB   )selfr@   r?   rB   s       r   __init__Zone.__init__}   s     &#&&++F366  ", - -%%'' !LMM
$r   c                     [        U[        5      (       d  gU R                  UR                  :w  d4  U R                  UR                  :w  d  U R                  UR                  :w  a  gg)zYTwo zones are equal if they have the same origin, class, and
nodes.

Returns a ``bool``.
FT)rD   r=   r?   r@   rA   rL   others     r   __eq__Zone.__eq__   sJ     %&&<<5==(;;%,,&::$r   c                 .    U R                  U5      (       + $ )z.Are two zones not equal?

Returns a ``bool``.
)rR   rP   s     r   __ne__Zone.__ne__   s     ;;u%%%r   c                    [        U[        5      (       a!  [        R                  R	                  US 5      nO4[        U[        R                  R
                  5      (       d  [        S5      eUR                  5       (       aW  UR                  U R                  5      (       d  [        S5      eU R                  (       a  UR                  U R                  5      nU$ )Nz0name parameter must be convertible to a DNS namez5name parameter must be a subdomain of the zone origin)rD   rE   rF   rG   rH   rI   KeyErrorrK   is_subdomainr@   rB   rL   rG   s     r   _validate_nameZone._validate_name   s    dC  88%%dD1DD#((--00MNN$$T[[11KM Mt{{3r   c                 B    U R                  U5      nU R                  U   $ Nr[   rA   rL   keys     r   __getitem__Zone.__getitem__   s     !!#&zz#r   c                 B    U R                  U5      nX R                  U'   g r^   r_   )rL   ra   values      r   __setitem__Zone.__setitem__   s    !!#&

3r   c                 @    U R                  U5      nU R                  U	 g r^   r_   r`   s     r   __delitem__Zone.__delitem__   s    !!#&JJsOr   c                 6    U R                   R                  5       $ r^   )rA   __iter__rL   s    r   rl   Zone.__iter__   s    zz""$$r   c                 6    U R                   R                  5       $ r^   )rA   keysrm   s    r   rp   	Zone.keys   s    zz  r   c                 6    U R                   R                  5       $ r^   )rA   valuesrm   s    r   rs   Zone.values   s    zz  ""r   c                 6    U R                   R                  5       $ r^   )rA   itemsrm   s    r   rv   
Zone.items   s    zz!!r   c                 Z    U R                  U5      nU R                  R                  U5      $ r^   )r[   rA   getr`   s     r   ry   Zone.get   s%    !!#&zz~~c""r   c                 @    U R                  U5      nXR                  ;   $ r^   r_   r`   s     r   __contains__Zone.__contains__   s    !!#&jj  r   Fc                     U R                  U5      nU R                  R                  U5      nUc+  U(       d  [        eU R	                  5       nX0R                  U'   U$ )a  Find a node in the zone, possibly creating it.

*name*: the name of the node to find.
The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
name must be a subdomain of the zone's origin.  If ``zone.relativize``
is ``True``, then the name will be relativized.

*create*, a ``bool``.  If true, the node will be created if it does
not exist.

Raises ``KeyError`` if the name is not known and create was
not specified, or if the name was not a subdomain of the origin.

Returns a ``dns.node.Node``.
)r[   rA   ry   rX   node_factoryrL   rG   createnodes       r   	find_nodeZone.find_node   sR    " ""4(zz~~d#<$$&D#JJtr   c                 P     U R                  X5      nU$ ! [         a    Sn U$ f = f)a  Get a node in the zone, possibly creating it.

This method is like ``find_node()``, except it returns None instead
of raising an exception if the node does not exist and creation
has not been requested.

*name*: the name of the node to find.
The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
name must be a subdomain of the zone's origin.  If ``zone.relativize``
is ``True``, then the name will be relativized.

*create*, a ``bool``.  If true, the node will be created if it does
not exist.

Raises ``KeyError`` if the name is not known and create was
not specified, or if the name was not a subdomain of the origin.

Returns a ``dns.node.Node`` or ``None``.
N)r   rX   r   s       r   get_nodeZone.get_node   s7    *	>>$/D   	D	s    %%c                 `    U R                  U5      nXR                  ;   a  U R                  U	 gg)a;  Delete the specified node if it exists.

*name*: the name of the node to find.
The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
name must be a subdomain of the zone's origin.  If ``zone.relativize``
is ``True``, then the name will be relativized.

It is not an error if the node does not exist.
Nr_   rZ   s     r   delete_nodeZone.delete_node  s/     ""4(::

4  r   c                 *   U R                  U5      n[        R                  R                  R	                  U5      nUb)  [        R                  R                  R	                  U5      nU R                  X5      nUR                  U R                  X#U5      $ )a  Look for an rdataset with the specified name and type in the zone,
and return an rdataset encapsulating it.

The rdataset returned is not a copy; changes to it will change
the zone.

KeyError is raised if the name or type are not found.

*name*: the name of the node to find.
The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
name must be a subdomain of the zone's origin.  If ``zone.relativize``
is ``True``, then the name will be relativized.

*rdtype*, an ``int`` or ``str``, the rdata type desired.

*covers*, an ``int`` or ``str`` or ``None``, the covered type.
Usually this value is ``dns.rdatatype.NONE``, but if the
rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
then the covers value will be the rdata type the SIG/RRSIG
covers.  The library treats the SIG and RRSIG types as if they
were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
This makes RRSIGs much easier to work with than if RRSIGs
covering different rdata types were aggregated into a single
RRSIG rdataset.

*create*, a ``bool``.  If true, the node will be created if it does
not exist.

Raises ``KeyError`` if the name is not known and create was
not specified, or if the name was not a subdomain of the origin.

Returns a ``dns.rdataset.Rdataset``.
)r[   rF   	rdatatype	RdataTypemaker   find_rdatasetr?   )rL   rG   rdtypecoversr   r   s         r   r   Zone.find_rdataset  sv    H ""4(((--f5]],,11&9F~~d+!!$,,GGr   c                 R     U R                  XX45      nU$ ! [         a    Sn U$ f = f)aC  Look for an rdataset with the specified name and type in the zone.

This method is like ``find_rdataset()``, except it returns None instead
of raising an exception if the rdataset does not exist and creation
has not been requested.

The rdataset returned is not a copy; changes to it will change
the zone.

*name*: the name of the node to find.
The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
name must be a subdomain of the zone's origin.  If ``zone.relativize``
is ``True``, then the name will be relativized.

*rdtype*, an ``int`` or ``str``, the rdata type desired.

*covers*, an ``int`` or ``str`` or ``None``, the covered type.
Usually this value is ``dns.rdatatype.NONE``, but if the
rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
then the covers value will be the rdata type the SIG/RRSIG
covers.  The library treats the SIG and RRSIG types as if they
were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
This makes RRSIGs much easier to work with than if RRSIGs
covering different rdata types were aggregated into a single
RRSIG rdataset.

*create*, a ``bool``.  If true, the node will be created if it does
not exist.

Raises ``KeyError`` if the name is not known and create was
not specified, or if the name was not a subdomain of the origin.

Returns a ``dns.rdataset.Rdataset`` or ``None``.
N)r   rX   )rL   rG   r   r   r   rdatasets         r   get_rdatasetZone.get_rdatasetJ  s<    J	))$GH   	H	    &&c                 t   U R                  U5      n[        R                  R                  R	                  U5      nUb)  [        R                  R                  R	                  U5      nU R                  U5      nUb>  UR                  U R                  X#5        [        U5      S:X  a  U R                  U5        ggg)a!  Delete the rdataset matching *rdtype* and *covers*, if it
exists at the node specified by *name*.

It is not an error if the node does not exist, or if there is no
matching rdataset at the node.

If the node has no rdatasets after the deletion, it will itself
be deleted.

*name*: the name of the node to find.
The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
name must be a subdomain of the zone's origin.  If ``zone.relativize``
is ``True``, then the name will be relativized.

*rdtype*, an ``int`` or ``str``, the rdata type desired.

*covers*, an ``int`` or ``str`` or ``None``, the covered type.
Usually this value is ``dns.rdatatype.NONE``, but if the
rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
then the covers value will be the rdata type the SIG/RRSIG
covers.  The library treats the SIG and RRSIG types as if they
were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
This makes RRSIGs much easier to work with than if RRSIGs
covering different rdata types were aggregated into a single
RRSIG rdataset.
Nr   )
r[   rF   r   r   r   r   delete_rdatasetr?   lenr   )rL   rG   r   r   r   s        r   r   Zone.delete_rdatasetu  s    8 ""4(((--f5]],,11&9F}}T"  v>4yA~  &  r   c                     UR                   U R                   :w  a  [        S5      eU R                  US5      nUR                  U5        g)ak  Replace an rdataset at name.

It is not an error if there is no rdataset matching I{replacement}.

Ownership of the *replacement* object is transferred to the zone;
in other words, this method does not store a copy of *replacement*
at the node, it stores *replacement* itself.

If the node does not exist, it is created.

*name*: the name of the node to find.
The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
name must be a subdomain of the zone's origin.  If ``zone.relativize``
is ``True``, then the name will be relativized.

*replacement*, a ``dns.rdataset.Rdataset``, the replacement rdataset.
z#replacement.rdclass != zone.rdclassTN)r?   rJ   r   replace_rdataset)rL   rG   replacementr   s       r   r   Zone.replace_rdataset  s@    & $,,.BCC~~dD)k*r   c                    U R                  U5      n[        R                  R                  R	                  U5      nUb)  [        R                  R                  R	                  U5      nU R
                  U   R                  U R                  X#5      n[        R                  R                  XR                  X#5      nUR                  U5        U$ )a  Look for an rdataset with the specified name and type in the zone,
and return an RRset encapsulating it.

This method is less efficient than the similar
``find_rdataset()`` because it creates an RRset instead of
returning the matching rdataset.  It may be more convenient
for some uses since it returns an object which binds the owner
name to the rdataset.

This method may not be used to create new nodes or rdatasets;
use ``find_rdataset`` instead.

*name*: the name of the node to find.
The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
name must be a subdomain of the zone's origin.  If ``zone.relativize``
is ``True``, then the name will be relativized.

*rdtype*, an ``int`` or ``str``, the rdata type desired.

*covers*, an ``int`` or ``str`` or ``None``, the covered type.
Usually this value is ``dns.rdatatype.NONE``, but if the
rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
then the covers value will be the rdata type the SIG/RRSIG
covers.  The library treats the SIG and RRSIG types as if they
were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
This makes RRSIGs much easier to work with than if RRSIGs
covering different rdata types were aggregated into a single
RRSIG rdataset.

*create*, a ``bool``.  If true, the node will be created if it does
not exist.

Raises ``KeyError`` if the name is not known and create was
not specified, or if the name was not a subdomain of the origin.

Returns a ``dns.rrset.RRset`` or ``None``.
)r[   rF   r   r   r   rA   r   r?   rrsetRRsetupdate)rL   rG   r   r   r   r   s         r   
find_rrsetZone.find_rrset  s    N ""4(((--f5]],,11&9F::d#11$,,O		llFCXr   c                 R     U R                  XU5      nU$ ! [         a    Sn U$ f = f)a  Look for an rdataset with the specified name and type in the zone,
and return an RRset encapsulating it.

This method is less efficient than the similar ``get_rdataset()``
because it creates an RRset instead of returning the matching
rdataset.  It may be more convenient for some uses since it
returns an object which binds the owner name to the rdataset.

This method may not be used to create new nodes or rdatasets;
use ``get_rdataset()`` instead.

*name*: the name of the node to find.
The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
name must be a subdomain of the zone's origin.  If ``zone.relativize``
is ``True``, then the name will be relativized.

*rdtype*, an ``int`` or ``str``, the rdata type desired.

*covers*, an ``int`` or ``str`` or ``None``, the covered type.
Usually this value is ``dns.rdatatype.NONE``, but if the
rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
then the covers value will be the rdata type the SIG/RRSIG
covers.  The library treats the SIG and RRSIG types as if they
were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
This makes RRSIGs much easier to work with than if RRSIGs
covering different rdata types were aggregated into a single
RRSIG rdataset.

*create*, a ``bool``.  If true, the node will be created if it does
not exist.

Raises ``KeyError`` if the name is not known and create was
not specified, or if the name was not a subdomain of the origin.

Returns a ``dns.rrset.RRset`` or ``None``.
N)r   rX   )rL   rG   r   r   r   s        r   	get_rrsetZone.get_rrset  s:    L	OOD&9E   	E	r   c              #     #    [         R                  R                  R                  U5      nUb)  [         R                  R                  R                  U5      nU R	                  5        HU  u  p4U HJ  nU[         R                  R
                  :X  d$  UR                  U:X  d  M3  UR                  U:X  d  ME  X54v   ML     MW     g7f)a  Return a generator which yields (name, rdataset) tuples for
all rdatasets in the zone which have the specified *rdtype*
and *covers*.  If *rdtype* is ``dns.rdatatype.ANY``, the default,
then all rdatasets will be matched.

*rdtype*, an ``int`` or ``str``, the rdata type desired.

*covers*, an ``int`` or ``str`` or ``None``, the covered type.
Usually this value is ``dns.rdatatype.NONE``, but if the
rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
then the covers value will be the rdata type the SIG/RRSIG
covers.  The library treats the SIG and RRSIG types as if they
were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
This makes RRSIGs much easier to work with than if RRSIGs
covering different rdata types were aggregated into a single
RRSIG rdataset.
N)rF   r   r   r   rv   ANYr   r   )rL   r   r   rG   r   rdss         r   iterate_rdatasetsZone.iterate_rdatasets  s     ( ((--f5]],,11&9F JJLLTS]]...JJ&(SZZ6-A+%  )s   BC"C4Cc              #     #    [         R                  R                  R                  U5      nUb)  [         R                  R                  R                  U5      nU R	                  5        Hi  u  p4U H^  nU[         R                  R
                  :X  d$  UR                  U:X  d  M3  UR                  U:X  d  ME  U H  nX5R                  U4v   M     M`     Mk     g7f)a  Return a generator which yields (name, ttl, rdata) tuples for
all rdatas in the zone which have the specified *rdtype*
and *covers*.  If *rdtype* is ``dns.rdatatype.ANY``, the default,
then all rdatas will be matched.

*rdtype*, an ``int`` or ``str``, the rdata type desired.

*covers*, an ``int`` or ``str`` or ``None``, the covered type.
Usually this value is ``dns.rdatatype.NONE``, but if the
rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
then the covers value will be the rdata type the SIG/RRSIG
covers.  The library treats the SIG and RRSIG types as if they
were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
This makes RRSIGs much easier to work with than if RRSIGs
covering different rdata types were aggregated into a single
RRSIG rdataset.
N)	rF   r   r   r   rv   r   r   r   ttl)rL   r   r   rG   r   r   rdatas          r   iterate_rdatasZone.iterate_rdatas,  s     ( ((--f5]],,11&9F JJLLTS]]...JJ&(SZZ6-A!$#WWe44 "%  )s   BC"C4"CNc           	      R   [         R                  " 5        n[        U[        5      (       a  UR	                  [        US5      5      n[        USS5      nUc  SnUc"  [        R                  R                  U5      n	SnO9[        U[        5      (       a  UR                  U5      n	OUn	UR                  5       nU(       aQ  SU R                  R                  5       -   n
U
R                  U5      n UR                  U5        UR                  U	5        U(       a*  [        U R!                  5       5      nUR#                  5         OU R!                  5       nU HT  nX   R                  XR                  UUS9n
U
R                  U5      n UR                  U5        UR                  U	5        MV     SSS5        g! [         a%    UR                  U
5        UR                  U5         Nf = f! [         a&    UR                  U
5        UR                  U5         M  f = f! , (       d  f       g= f)a  Write a zone to a file.

*f*, a file or `str`.  If *f* is a string, it is treated
as the name of a file to open.

*sorted*, a ``bool``.  If True, the default, then the file
will be written with the names sorted in DNSSEC order from
least to greatest.  Otherwise the names will be written in
whatever order they happen to have in the zone's dictionary.

*relativize*, a ``bool``.  If True, the default, then domain
names in the output will be relativized to the zone's origin
if possible.

*nl*, a ``str`` or None.  The end of line string.  If not
``None``, the output will use the platform's native
end-of-line marker (i.e. LF on POSIX, CRLF on Windows).

*want_comments*, a ``bool``.  If ``True``, emit end-of-line comments
as part of writing the file.  If ``False``, the default, do not
emit them.

*want_origin*, a ``bool``.  If ``True``, emit a $ORIGIN line at
the start of the file.  If ``False``, the default, do not emit
one.
wbencodingNzutf-8
z$ORIGIN )r@   rB   want_comments)
contextlib	ExitStackrD   rE   enter_contextopengetattroslinesepencodedecoder@   to_textwrite	TypeErrorlistrp   sort)rL   fsortedrB   nlr   want_originstackfile_encnl_bll_bnamesns                 r   to_fileZone.to_fileJ  s   : !!#u!S!!''Q6 q*d3H"zzz((2B$$yy*YY[!4!4!66hhx( GGCLGGDM
 TYY[)

		GOOAkk/92? $ A hhx( GGCLGGDM G $#4 !  GGAJGGBK $ !  GGAJGGBK Y $#sU   CH-"F3A4H"G%&H3,G"H!G""H%,HHHH
H&c                     [         R                  " 5       nU R                  XaX#UU5        UR                  5       nUR	                  5         U$ )a  Return a zone's text as though it were written to a file.

*sorted*, a ``bool``.  If True, the default, then the file
will be written with the names sorted in DNSSEC order from
least to greatest.  Otherwise the names will be written in
whatever order they happen to have in the zone's dictionary.

*relativize*, a ``bool``.  If True, the default, then domain
names in the output will be relativized to the zone's origin
if possible.

*nl*, a ``str`` or None.  The end of line string.  If not
``None``, the output will use the platform's native
end-of-line marker (i.e. LF on POSIX, CRLF on Windows).

*want_comments*, a ``bool``.  If ``True``, emit end-of-line comments
as part of writing the file.  If ``False``, the default, do not
emit them.

*want_origin*, a ``bool``.  If ``True``, emit a $ORIGIN line at
the start of the output.  If ``False``, the default, do not emit
one.

Returns a ``str``.
)ioStringIOr   getvalueclose)rL   r   rB   r   r   r   temp_bufferreturn_values           r   r   Zone.to_text  sD    6 kkm[*- 	""++-r   c                 8   U R                   (       a  [        R                  R                  nOU R                  nU R                  U[        R                  R                  5      c  [        eU R                  U[        R                  R                  5      c  [        eg)zDo some simple checking of the zone's origin.

Raises ``dns.zone.NoSOA`` if there is no SOA RRset.

Raises ``dns.zone.NoNS`` if there is no NS RRset.

Raises ``KeyError`` if there is no origin node.
N)rB   rF   rG   emptyr@   r   r   SOAr   NSr   rZ   s     r   check_originZone.check_origin  sj     ??88>>D;;DT3==#4#45=KT3==#3#34<J =r   c           	      j   [         R                  U5      nU(       d  [        eU[        R                  :w  a  [
        eU R                  (       a  [        R                  R                  nOU R                  nU" 5       n[        U R                  5       5       GH  u  pgUR                  U R                  5      n[        US S9 H  n	Xd:X  a6  [        R                  R                  U	R                   U	R"                  4;   a  M>  [$        R&                  " SU	R                   U	R(                  U	R*                  5      n
[        U	5       HW  nUR                  U R                  5      n[$        R&                  " S[-        U5      5      nUR/                  X-   U-   U-   5        MY     M     GM     UR1                  5       $ )Nc                 2    U R                   U R                  4$ r^   )r   r   )r   s    r   <lambda>&Zone._compute_digest.<locals>.<lambda>  s    CJJ

3Kr   )ra   z!HHIz!H)_digest_hashersry   r   r'   r2   r   rB   rF   rG   r   r@   r   rv   to_digestabler   ZONEMDr   r   structpackr?   r   r   r   digest)rL   hash_algorithmschemehashinfoorigin_namehasherrG   r   	rrnamebufr   rrfixedrrrrdatarrlens                 r   _compute_digestZone._compute_digest  s@   "&&~600\((())??((..K++K"4::<0LT**4;;7I"4'KM&==''HOOX__+MM ++fhoo&.&6&6F *B--dkk:F"KKc&k:EMM)"5"="FG +M 1 }}r   c                    U R                   (       a  [        R                  R                  nOU R                  nU R                  U[        R                  R                  5      S   R                  nU R                  X5      n[        R                  R                  R                  R                  U R                  [        R                  R                  XBUU5      $ Nr   )rB   rF   rG   r   r@   r   r   r   serialr   rdtypesr   r   r?   )rL   r   r   r   r   r   s         r   compute_digestZone.compute_digest  s    ??((..K++K"";0A0AB1ELL%%n={{%%,,T\\-0]]-A-A-3^-35 	5r   c                 B   U(       a  U/nO=U R                  U R                  [        R                  R                  5      nUc  [
        eU H;  n U R                  UR                  UR                  5      nXCR                  :X  a    g M=     [        e! [         a     MR  f = fr^   )r   r@   rF   r   r   r!   r   r   r   r   	Exceptionr$   )rL   zonemddigestsr   computeds        r   verify_digestZone.verify_digest  s    hG''S]]5I5IJGF//0E0E06?}}, -	  ('  s   5B
BBc                     [        U SS5      $ )NFTTransactionrm   s    r   readerZone.reader  s    4--r   c                     [        XS5      $ )NFr  )rL   r   s     r   writerZone.writer  s    4e44r   c                     U R                   (       a  [        R                  R                  nOU R                  nU R                  U R                   U4$ r^   )rB   rF   rG   r   r@   )rL   	effectives     r   origin_informationZone.origin_information  s4    ??IIT__i88r   c                     U R                   $ r^   )r?   rm   s    r   	get_classZone.get_class  s    ||r   )rA   r@   r?   rB   )F)TTNFFr^   )4r   r	   r
   r   r   rF   r   Noder   	__slots__
rdataclassINrM   rR   rU   r[   rb   rf   ri   rl   rp   rs   rv   ry   r|   r   r   r   r   NONEr   r   r   r   r   r   r   r   r   r   r   r   r'   r2   r   r   r  r  r
  r  r  r   r   r   r   r=   r=   m   s    88==L<I'*~~'8'8T %4& %!#"#!46! 251C1C")HV 140B0B!)V 47==3E3E $'L+0 /2mm.@.@ .` .1]]-?-? *X (+}}'8'8!$!3!3&: %(MM$5$5!mm005< ;?16K Z 8<16 D$ 6B5H5H 6 5A4G4G 
5(&.59r   r=   c                      ^  \ rS rSr\R
                  R                  \R                  R                  \R                  R                  5      r
U 4S jr\S 5       rS rS rS rS rS rS	 rS
 rS rS rSrU =r$ )r  i  c                 4   > [         TU ]  XU5        0 U l        g r^   )superrM   	rdatasets)rL   zoner   	read_only	__class__s       r   rM   Transaction.__init__  s    I6r   c                     U R                   $ r^   )managerrm   s    r   r  Transaction.zone  s    ||r   c                     U R                   R                  XU45      nX@R                  L a  g Uc  U R                  R	                  XU5      nU$ r^   )r  ry   _deleted_rdatasetr  r   rL   rG   r   r   r   s        r   _get_rdatasetTransaction._get_rdataset#  sK    >>%%tV&<=---yy--dFCHr   c                     U R                   R                  U5        X R                  XR                  UR                  4'   g r^   )r  r[   r  r   r   )rL   rG   r   s      r   _put_rdatasetTransaction._put_rdataset+  s-    		  &CKoox?@r   c                 r   / nU R                    H  nUS   U:X  d  M  UR                  U5        M!     [        U5      S:  a  U H  nU R                   U	 M     U R                  R	                  U5      nUbC  UR                    H2  nU R
                  U R                   XR                  UR                  4'   M4     g g r   )r  appendr   r  r   r$  r   r   )rL   rG   removera   r   r   s         r   _delete_nameTransaction._delete_name0  s     >>C1v~c" " v;?NN3'  yy!!$' NN** ooxGH + r   c                      U R                   XU4	 U R                  R                  XU5      nUb0  U R                  U R                   XR
                  UR                  4'   g g ! [         a     N\f = fr^   )r  rX   r  r   r$  r   r   r%  s        r   _delete_rdatasetTransaction._delete_rdatasetB  ss    	f56 99))$?&& NND//8??CD    		s   A! !
A.-A.c                     U R                   R                  5        H!  u  p#US   U:X  d  M  X0R                  :w  a    g  g    U R                  R	                  U5        U R                  R                  U5      (       a  gg)Nr   TF)r  rv   r$  r  r[   r   )rL   rG   ra   r   s       r   _name_existsTransaction._name_existsM  sg    !^^113MC1v~555 4 			  &99d##r   c                 V    U R                   (       a  g[        U R                  5      S:  $ )NFr   )r  r   r  rm   s    r   _changedTransaction._changedY  s     >>t~~&**r   c                    U(       a  U R                  5       (       an  U R                  R                  5        HO  u  u  p#pEXPR                  L a  U R                  R                  X#U5        M4  U R                  R                  X%5        MQ     g g g r^   )r7  r  rv   r$  r  r   r   )rL   commitrG   r   r   r   s         r   _end_transactionTransaction._end_transaction_  si    dmmoo$$& 1&v555II--dFCII..t>	 ' &6r   c                 T    U R                   R                  c  XR                   l        g g r^   )r  r@   )rL   r@   s     r   _set_originTransaction._set_originh  s!    99#%II $r   c              #     #    0 nU R                   R                  5        H  u  p#X1X#R                  UR                  4'   M!     UR	                  U R
                  5        UR                  5        H  u  u  n  pCX#4v   M     g 7fr^   )r  r   r   r   r   r  rv   )rL   r  rG   r   _s        r   _iterate_rdatasetsTransaction._iterate_rdatasetsl  sp      	 $		 ; ; =TBJt__hoo>? !>(&/oo&7"LT1a"" '8s   A>B )r  )r   r	   r
   r   rF   r   Rdatasetr  r   r   r$  rM   propertyr  r&  r)  r.  r1  r4  r7  r;  r>  rB  r   __classcell__)r  s   @r   r  r    s~    --cnn.@.@.1mm.?.?A  L
+$	'
+?&# #r   r  TFc	                    Uc  SnU" XUS9n	U	R                  S5       n
[        R                  R                  XUS9n[        R                  R                  XU
US9n UR                  5          SSS5        U(       a  U	R                  5         U	$ ! [        R                  R                   a    [        R                  R                  ef = f! , (       d  f       Nc= f)a  Build a zone object from a zone file format string.

*text*, a ``str``, the zone file format input.

*origin*, a ``dns.name.Name``, a ``str``, or ``None``.  The origin
of the zone; if not specified, the first ``$ORIGIN`` statement in the
zone file will determine the origin of the zone.

*rdclass*, an ``int``, the zone's rdata class; the default is class IN.

*relativize*, a ``bool``, determine's whether domain names are
relativized to the zone's origin.  The default is ``True``.

*zone_factory*, the zone factory to use or ``None``.  If ``None``, then
``dns.zone.Zone`` will be used.  The value may be any class or callable
that returns a subclass of ``dns.zone.Zone``.

*filename*, a ``str`` or ``None``, the filename to emit when
describing where an error occurred; the default is ``'<string>'``.

*allow_include*, a ``bool``.  If ``True``, the default, then ``$INCLUDE``
directives are permitted.  If ``False``, then encoutering a ``$INCLUDE``
will raise a ``SyntaxError`` exception.

*check_origin*, a ``bool``.  If ``True``, the default, then sanity
checks of the origin node will be made by calling the zone's
``check_origin()`` method.

*idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA
encoder/decoder.  If ``None``, the default IDNA 2003 encoder/decoder
is used.

Raises ``dns.zone.NoSOA`` if there is no SOA RRset.

Raises ``dns.zone.NoNS`` if there is no NS RRset.

Raises ``KeyError`` if there is no origin node.

Returns a subclass of ``dns.zone.Zone``.
Nz<string>rB   T)
idna_codec)allow_include)
r
  rF   	tokenizer	TokenizerzonefileReaderreadr   r  r   )textr@   r?   rB   zone_factoryfilenamerJ  r   rI  r  txntokr  s                r   rH   rH   w  s    ` J?D	T	cmm%%d%L$$S33@ % B	)KKM 
 K ||)) 	)(((((	) 
	s   >CB9CC
Cc                     [         R                  " 5        n[        U [        5      (       a  Uc  U nUR	                  [        U 5      5      n [        XX#UXVU5      sSSS5        $ ! , (       d  f       g= f)a  Read a zone file and build a zone object.

*f*, a file or ``str``.  If *f* is a string, it is treated
as the name of a file to open.

*origin*, a ``dns.name.Name``, a ``str``, or ``None``.  The origin
of the zone; if not specified, the first ``$ORIGIN`` statement in the
zone file will determine the origin of the zone.

*rdclass*, an ``int``, the zone's rdata class; the default is class IN.

*relativize*, a ``bool``, determine's whether domain names are
relativized to the zone's origin.  The default is ``True``.

*zone_factory*, the zone factory to use or ``None``.  If ``None``, then
``dns.zone.Zone`` will be used.  The value may be any class or callable
that returns a subclass of ``dns.zone.Zone``.

*filename*, a ``str`` or ``None``, the filename to emit when
describing where an error occurred; the default is ``'<string>'``.

*allow_include*, a ``bool``.  If ``True``, the default, then ``$INCLUDE``
directives are permitted.  If ``False``, then encoutering a ``$INCLUDE``
will raise a ``SyntaxError`` exception.

*check_origin*, a ``bool``.  If ``True``, the default, then sanity
checks of the origin node will be made by calling the zone's
``check_origin()`` method.

*idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA
encoder/decoder.  If ``None``, the default IDNA 2003 encoder/decoder
is used.

Raises ``dns.zone.NoSOA`` if there is no SOA RRset.

Raises ``dns.zone.NoNS`` if there is no NS RRset.

Raises ``KeyError`` if there is no origin node.

Returns a subclass of ``dns.zone.Zone``.
N)r   r   rD   rE   r   r   rH   )	r   r@   r?   rB   rQ  rR  rJ  r   r   s	            r   	from_filerV    s_    Z 
			5a##DG,AG!,@ 
 		s   AA##
A1c                    SnU  GH"  nUcM  U(       a  UR                   nOUR                  S   R                  nUR                  S   R                  nU" XgUS9nUR                   H  nUR                  R                  UR                  5      n	U	(       d(  UR                  5       n	XR                  UR                  '   U	R                  UR                  UR                  UR                  S5      n
U
R                  UR                  5        U H  nU
R                  U5        M     M     GM%     U(       a  UR                  5         U$ )a  Convert the output of a zone transfer generator into a zone object.

*xfr*, a generator of ``dns.message.Message`` objects, typically
``dns.query.xfr()``.

*relativize*, a ``bool``, determine's whether domain names are
relativized to the zone's origin.  The default is ``True``.
It is essential that the relativize setting matches the one specified
to the generator.

*check_origin*, a ``bool``.  If ``True``, the default, then sanity
checks of the origin node will be made by calling the zone's
``check_origin()`` method.

Raises ``dns.zone.NoSOA`` if there is no SOA RRset.

Raises ``dns.zone.NoNS`` if there is no NS RRset.

Raises ``KeyError`` if there is no origin node.

Returns a subclass of ``dns.zone.Zone``.
Nr   rH  T)r@   answerrG   r?   rA   ry   r   r   r   r   
update_ttlr   addr   )xfrrQ  rB   r   zrr@   r?   r   znodezrdsrds               r   from_xfrra    s    0 	A9!))hhqk))GVDAXXEGGKK

+E(&+

#&&u}}ell',||T;DOOEII&   $ 	Hr   )1r   r   hashlibr   r   r   dns.exceptionrF   dns.namedns.nodedns.rdataclassdns.rdatatype	dns.rdatadns.rdtypes.ANY.SOAdns.rdtypes.ANY.ZONEMD	dns.rrsetdns.tokenizerdns.transactiondns.ttl
dns.grangedns.zonefile	exceptionDNSExceptionr   r   r   r   r   r   r!   r$   enumIntEnumr'   r5   r:   sha384r;   sha512r   transactionTransactionManagerr=   r  r  r  rH   rV  ra  r   r   r   <module>ry     s  $    	 	               %cmm(( %
4G 4
67 6
,G ,
3cmm88 3
3S]]%?%? 3
:s}})) :
. : : .
388## #((**  f
3??-- f
R^##//-- ^#B  ):):D4!?D cnn&7&7D4 t3@l  $4 -r   