o
    uvXjF  ã                   @   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   sd   zt  tt  | ¡ƒ¡}W n ty   t|dd�‚w |r$|jr$t|jƒS |jr.d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_strÚunpack_ipv4Úerror_messageÚaddr© r   úN/var/www/html/myproject/venv/lib/python3.10/site-packages/django/utils/ipv6.pyÚclean_ipv6_address   s   ÿ

r   c                 C   s&   zt  | ¡ W dS  ty   Y dS w )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   Údjango.core.exceptionsr   Údjango.utils.translationr   Ú_r   r   r   r   r   r   Ú<module>   s    
ÿ