a
    Lcòf5  ã                   @   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   sh   zt  tt  | ¡ƒ¡}W n ty6   t|dd�‚Y n0 |rL|jrLt|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_strZunpack_ipv4Úerror_messageÚaddr© r   úN/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/django/utils/ipv6.pyÚclean_ipv6_address   s    

r   c                 C   s(   zt  | ¡ W n ty"   Y dS 0 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
   ÿ
 