
    hy                        S r SSKrSSKJrJr  SSKrSSKr\R                  r\R                  r	S\
S\S\4S jrS\
S\S\4S	 jrS\S\
4S
 jrS\S\4S jrS\S\4S jrSS\\\
4   S\
S-  S\4S jjrS rS\S\4S jrg)z*Generic Internet address helper functions.    N)AnyTuplefamilytextreturnc                     U [         :X  a  [        R                  R                  U5      $ U [        :X  a   [        R
                  R                  US5      $ [        e)a  Convert the textual form of a network address into its binary form.

*family* is an ``int``, the address family.

*text* is a ``str``, the textual address.

Raises ``NotImplementedError`` if the address family specified is not
implemented.

Returns a ``bytes``.
T)AF_INETdnsipv4	inet_atonAF_INET6ipv6NotImplementedError)r   r   s     ]C:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\dns/inet.py	inet_ptonr   !   sF     xx!!$''	8	xx!!$--!!    addressc                     U [         :X  a  [        R                  R                  U5      $ U [        :X  a  [        R
                  R                  U5      $ [        e)a  Convert the binary form of a network address into its textual form.

*family* is an ``int``, the address family.

*address* is a ``bytes``, the network address in binary form.

Raises ``NotImplementedError`` if the address family specified is not
implemented.

Returns a ``str``.
)r	   r
   r   	inet_ntoar   r   r   )r   r   s     r   	inet_ntopr   6   sD     xx!!'**	8	xx!!'**!!r   c                      [         R                  R                  U 5        [        $ ! [         a>     [         R
                  R                  U S5        [        s $ ! [         a    [        ef = ff = f)zDetermine the address family of a textual-form network address.

*text*, a ``str``, the textual address.

Raises ``ValueError`` if the address family cannot be determined
from the input.

Returns an ``int``.
T)r
   r   r   r	   	Exceptionr   r   
ValueErrorr   s    r   af_for_addressr   K   s`    4  	HHtT*O 			s    $' 
A/%AA/A++A/c                     [         R                  R                  U 5      S   nUS:  =(       a    US:*  $ ! [         a@     [         R                  R                  U S5      S   nUS:H  s $ ! [         a    [
        ef = ff = f)zIs the textual-form network address a multicast address?

*text*, a ``str``, the textual address.

Raises ``ValueError`` if the address family cannot be determined
from the input.

Returns a ``bool``.
r         T   )r
   r   r   r   r   r   )r   firsts     r   is_multicastr!   a   s    ""4(+|,, 	HH&&tT215EC< 			s!   25 
A? 'A*'A?*A;;A?c                      [         R                  R                  U 5        g! [         a5     [         R                  R                  U S5         g! [         a      gf = ff = f)zoIs the specified string an IPv4 or IPv6 address?

*text*, a ``str``, the textual address.

Returns a ``bool``.
TF)r
   r   r   r   r   r   s    r   
is_addressr#   w   sY    4  	HHtT* 			s&   " 
A! A
AA!AA!
high_tupleafc                    U u  p#Uc  [        U5      nU[        :X  a  X#4$ U[        :X  ae  UR                  S5      nUS:  a  X#SS4$ USU nX$S-   S nUR	                  5       (       a  XSS[        U5      4$  XSS[        R                  " U5      4$ [        SU 35      e! [         a.    [        R                  n[        R                  " X#US9tGt pnU	s $ f = f)a@  Given a "high-level" address tuple, i.e.
an (address, port) return the appropriate "low-level" address tuple
suitable for use in socket calls.

If an *af* other than ``None`` is provided, it is assumed the
address in the high-level tuple is valid and has that af.  If af
is ``None``, then af_for_address will be called.
N%r      )flagsunknown address family )r   r	   r   findisdigitintsocketif_nametoindexAttributeErrorAI_NUMERICHOSTgetaddrinfor   )
r$   r%   r   portiaddrpartscopeai_flags_tups
             r   low_level_address_tupler:      s     MG	zG$	W}	xLLq51a((2A;A ==??As5z22	Av'<'<U'CDD "$;B4"@AA  	,,H$00hOOYqJ	s   6B 5CCc                 r    U [         R                  :X  a  gU [         R                  :X  a  g[        SU  35      e)z:Return the 'any' address for the specified address family.z0.0.0.0z::r*   )r.   r	   r   r   )r%   s    r   
any_for_afr<      s3    	V^^	v	
 7t<
==r   c                      [         R                  R                  U 5      $ ! [         a7     [         R                  R                  U 5      s $ ! [         a    [
        ef = ff = f)zVerify that *address* is a valid text form IPv4 or IPv6 address and return its
canonical text form.  IPv6 addresses with scopes are rejected.

*text*, a ``str``, the address in textual form.

Raises ``ValueError`` if the text is not valid.
)r
   r   canonicalizer   r   r   r   s    r   r>   r>      sZ    xx$$T** 	88((.. 		s    ! 
A"A
A"AA")N)__doc__r.   typingr   r   dns.ipv4r
   dns.ipv6r	   r   r-   strbytesr   r   r   boolr!   r#   r:   r<   r>    r   r   <module>rG      s   $ 1    
 ..??"c " " "*"c "E "c "*  ,s t ,S T &Bc3h BS4Z BSV BD>s s r   