
    0                     0    d Z ddlZddlZddlmZ d Zd Zy)zIPv4 helper functions.    N   )binary_typec                     t        |       dk7  rt        j                  j                  t	        | t
              st        |       } d| d   | d   | d   | d   fz  S )zConvert an IPv4 address in binary form to text form.

    *address*, a ``binary``, the IPv4 address in binary form.

    Returns a ``text``.
       z%u.%u.%u.%ur   r         )lendns	exceptionSyntaxError
isinstance	bytearray)addresss    lib/third_party/dns/ipv4.py	inet_ntoar      s_     7|qmm'''gy)G$WQZ$QZ5 5 6    c                    t        | t              s| j                         } | j                  d      }t	        |      dk7  rt
        j                  j                  |D ]]  }|j                         st
        j                  j                  t	        |      dkD  s<|d   dk(  sEt
        j                  j                   	 |D cg c]  }t        |       }}t        j                  dg| S c c}w #  t
        j                  j                  xY w)zConvert an IPv4 address in text form to binary form.

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

    Returns a ``binary``.
       .r   r   r   0BBBB)r   r   encodesplitr	   r
   r   r   isdigitintstructpack)textpartspartbytess       r   	inet_atonr!   (   s     dK({{}JJtE
5zQmm'''||~--+++t9q=T!W^--+++ (',-utTu-{{6*E** .(mm'''s   =C0 C+C0 +C0 0D)__doc__r   dns.exceptionr
   _compatr   r   r!    r   r   <module>r&      s   $     6(r   