File: //opt/alt/python311/lib/python3.11/site-packages/validators/__pycache__/domain.cpython-311.pyc
�
�;f� �
�b � d Z ddlmZ ddlZddlmZ d� Zedddd�d ed
ededefd
�� � Z dS )zDomain.� )�PathN� )� validatorc # � K � t t � � j � d� � � � � 5 } t | � � }| D ]}|� � � V � � ddd� � dS # 1 swxY w Y dS )zLoad IANA TLDs as a Generator.z_tld.txtN)r �__file__�parent�joinpath�open�next�strip)�tld_f�_�lines �D/opt/alt/python311/lib/python3.11/site-packages/validators/domain.py� _iana_tldr s� � � � �
�h��� � '� '�
� 3� 3� 8� 8� :� :� �e���K�K��� � �D��*�*�,�,����� �� � � � � � � � � � � ���� � � � � � s �+A:�:A>�A>F)�consider_tld�rfc_1034�rfc_2782�valuer r r c � � | sdS |rQ| � d� � � dd� � d � � � t � � vrdS |rdnd}|rdnd}t j d | � � o`t j d
|� d�d|� d
�z d|� d�z dz d|� �z | � d� � � d� � t j � � S # t $ r}t d| � �� � |�d}~ww xY w)a& Return whether or not given value is a valid domain.
Examples:
>>> domain('example.com')
# Output: True
>>> domain('example.com/')
# Output: ValidationError(func=domain, ...)
>>> # Supports IDN domains as well::
>>> domain('xn----gtbspbbmkef.xn--p1ai')
# Output: True
Args:
value:
Domain string to validate.
consider_tld:
Restrict domain to TLDs allowed by IANA.
rfc_1034:
Allows optional trailing dot in the domain name.
Ref: [RFC 1034](https://www.rfc-editor.org/rfc/rfc1034).
rfc_2782:
Domain name is of type service record.
Allows optional underscores in the domain name.
Ref: [RFC 2782](https://www.rfc-editor.org/rfc/rfc2782).
Returns:
(Literal[True]): If `value` is a valid domain name.
(ValidationError): If `value` is an invalid domain name.
Raises:
(UnicodeError): If `value` cannot be encoded into `idna` or decoded into `utf-8`.
F�.r ���r � z\.?$�$z\s|__+z^(?:[a-z0-9�]z(?:[a-z0-9-z]{0,61}z[a-z0-9z])?\.)z+[a-z0-9][a-z0-9-_]{0,61}z[a-z]�idnazutf-8zUnable to encode/decode N)�rstrip�rsplit�upperr �re�search�match�encode�decode�
IGNORECASE�UnicodeError)r r r r �service_record�trailing_dot�errs r �domainr* sZ � �H � ��u�� ����S�)�)�0�0��a�8�8��<�B�B�D�D�I�K�K�W�W��u�H�!)�1���r��"*�4�w�w����9�Y��.�.�.�
�2�8�,�>�,�,�,�6�^�6�6�6�
7� 0��/�/�/�
0� +�
+� &�|�%�%�
&�
�L�L�� � �'�'��0�0��M�
4
�
4
�
�� � H� H� H��=�e�=�=�>�>�C�G�����H���s �BC �
C>�&C9�9C>)
�__doc__�pathlibr r �utilsr r �str�boolr* � � r �<module>r2 s� ��
�
� � � � � � � � � � � � � � � � �� � � �+0�5�[`�=H� =H� =H��=H�$(�=H�<@�=H�TX�=H� =H� =H� ��=H� =H� =Hr1