o
    'h	                     @   sj   d Z ddlZddlmZ ddlZdedefddZdeeef defd	d
Z	deeef defddZ
dS )zIPv4 helper functions.    N)Unionaddressreturnc                 C   s4   t | dkr
tjjd| d | d | d | d f S )zConvert an IPv4 address in binary form to text form.

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

    Returns a ``str``.
       z%u.%u.%u.%ur            )lendns	exceptionSyntaxError)r    r   D/var/www/html/olx_land/venv/lib/python3.10/site-packages/dns/ipv4.py	inet_ntoa   s    r   textc                 C   s   t | ts
|  }n| }|d}t|dkrtjj|D ]}| s'tjjt|dkr9|d t	dkr9tjjqzdd |D }t
jdg|R  W S  tyV   tjjw )	zConvert an IPv4 address in text form to binary form.

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

    Returns a ``bytes``.
       .r   r   r   0c                 S   s   g | ]}t |qS r   )int).0partr   r   r   
<listcomp>=   s    zinet_aton.<locals>.<listcomp>BBBB)
isinstancebytesencodesplitr	   r
   r   r   isdigitordstructpack	Exception)r   btextpartsr   br   r   r   	inet_aton'   s$   


r$   c                 C   s   t jt j| S )zVerify that *address* is a valid text form IPv4 address and return its
    canonical text form.

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

    Raises ``dns.exception.SyntaxError`` if the text is not valid.
    )r
   ipv4r   r$   )r   r   r   r   canonicalizeC   s   
r&   )__doc__r   typingr   dns.exceptionr
   r   strr   r$   r&   r   r   r   r   <module>   s   