
    Vh                         d dl mZmZmZ eZd dlZd dlmZ  ej                  d      Z
d Z G d de      Zd Zdd	Zd
 Zy)    )absolute_importdivisionprint_functionN)to_textz^[\x20-\x7e]*$c                 0    t         j                  |       duS )z:
    Check whether domain name has only ASCII labels.
    N)_ASCII_PRINTABLE_MATCHERmatch)domains    l/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/dns/plugins/module_utils/names.pyis_ascii_labelr      s     $))&1==    c                       e Zd ZdZy)InvalidDomainNamez0
    The provided domain name is not valid.
    N)__name__
__module____qualname____doc__ r   r   r   r      s    r   r   c                 0   g }t        |       }d}| j                  d      r|dz  }d}|dkD  rg|dk\  rb| j                  dd|      }| |dz   | }|dk(  s|d   dk(  s|d   dk(  st        |      dkD  rt        |       |j	                  |       |}|dk\  rb||fS )z
    Split domain name to a list of labels. Start with the top-most label.

    Returns a list of labels and a tail, which is either ``''`` or ``'.'``.
    Raises ``InvalidDomainName`` if the domain name is not valid.
     .   r   -?   )lenendswithrfindr   append)r
   resultindextail
next_indexlabels         r   split_into_labelsr%   !   s     FKEDs
qyqjc1e4J:>%0E{eAh#orc1ASZRT_'//MM% E qj 4<r   c                 <    dj                  t        |             |z   S )zM
    Combines the result of split_into_labels() back into a domain name.
    r   )joinreversed)labelsr"   s     r   join_labelsr*   9   s     88HV$%,,r   c                     t        |       s&t        dt        |       j                  d      z         } | j                         S )z
    Normalize a domain label. Returns a lower-case ASCII label.

    If a ulabel is provided, it is converted to an alabel.
    s   xn--punycode)r   r   encodelower)r$   s    r   normalize_labelr/   @   s6     % '%."7"7
"CCD;;=r   )r   )
__future__r   r   r   type__metaclass__re+ansible.module_utils.common.text.convertersr   compiler   r   	Exceptionr   r%   r*   r/   r   r   r   <module>r7      sO    A @  	 ? &2::&78 >	 0-
r   