U
    aF                     @   s>   d dl Z d dlmZ d dlmZ dedfddZdd	 ZdS )
    N)ValidationError)gettext_lazyFz!This is not a valid IPv6 address.c                 C   sj   zt tt | }W n  tk
r8   t|ddY nX |rN|jrNt|jS |jrbdt|j S t|S )a  
    Clean an IPv6 address string.

    Raise ValidationError if the address is invalid.

    Replace the longest continuous zero-sequence with "::", remove leading
    zeroes, and make sure all hextets are lowercase.

    Args:
        ip_str: A valid IPv6 address.
        unpack_ipv4: if an IPv4-mapped address is found,
        return the plain IPv4 address (default=False).
        error_message: An error message used in the ValidationError.

    Return a compressed IPv6 address or the same value.
    invalid)codez	::ffff:%s)	ipaddressIPv6Addressint
ValueErrorr   ipv4_mappedstr)ip_strZunpack_ipv4error_messageaddr r   /home/adriano.carvalho/ftp/files/BrinquedotecaVirtual/brinquedotecavirtual/venv/lib/python3.8/site-packages/django/utils/ipv6.pyclean_ipv6_address   s    

r   c                 C   s*   zt |  W n tk
r$   Y dS X dS )zL
    Return whether or not the `ip_str` string is a valid IPv6 address.
    FT)r   r   r	   )r   r   r   r   is_valid_ipv6_address&   s
    r   )r   Zdjango.core.exceptionsr   Zdjango.utils.translationr   _r   r   r   r   r   r   <module>   s   
