
    ^h                     ,    S SK r S SKJr   " S S5      rg)    N)cached_propertyc                       \ rS rSrSrSrSrS rS r\	S 5       r
\S 5       r\	S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       rS rS rSrg)FQDN   a  
From https://tools.ietf.org/html/rfc1035#page-9,  RFC 1035 3.1. Name space
definitions:

    Domain names in messages are expressed in terms of a sequence of
    labels. Each label is represented as a one octet length field followed
    by that number of octets.  Since every domain name ends with the null
    label of the root, a domain name is terminated by a length byte of
    zero.  The high order two bits of every length octet must be zero, and
    the remaining six bits of the length field limit the label to 63 octets
    or less.

    To simplify implementations, the total length of a domain name (i.e.,
    label octets and label length octets) is restricted to 255 octets or
    less.


Therefore the max length of a domain name is actually 253 ASCII bytes
without the trailing null byte or the leading length byte, and the max
length of a label is 63 bytes without the leading length byte.
z@^((?![-])[-A-Z\d]{1,63}(?<!-)[.])*(?!-)[-A-Z\d]{1,63}(?<!-)[.]?$zB^((?![-])[-_A-Z\d]{1,63}(?<!-)[.])*(?!-)[-_A-Z\d]{1,63}(?<!-)[.]?$c                 z   U(       a  [        S5      e[        UR                  5       5      SS1-
  nU(       a  [        SR                  U5      5      eU(       a  [	        U[
        5      (       d  [        S5      eUR                  5       U l        UR                  SS5      U l	        UR                  SS5      U l
        g )Nz*got extra positional parameter, try kwargsallow_underscores
min_labelszgot extra kwargs: {}zfqdn must be strF   )
ValueErrorsetkeysformat
isinstancestrlower_fqdnget_allow_underscores_min_labels)selffqdnnothingkwargsunknown_kwargss        G/home/james-whalen/.local/lib/python3.13/site-packages/fqdn/__init__.py__init__FQDN.__init__$   s    IJJV[[]+/BL.QQ3::>JKKD#../00ZZ\
"(**-@%"H!::lA6    c                     U R                   $ )'
The FQDN as a string in absolute form
)absoluter   s    r   __str__FQDN.__str__1   s     }}r   c                     U R                   (       d  [        R                  O[        R                  n[        R
                  " U[        R                  5      $ N)r   r   PREFERRED_NAME_SYNTAX_REGEXSTRALLOW_UNDERSCORES_REGEXSTRrecompile
IGNORECASE)r   regexstrs     r   _regexFQDN._regex7   s=     ** //00 	
 zz(BMM22r   c                    [        U R                  5      nU R                  R                  S5      (       a  US-  nUS:  a  gU R                  R	                  U R                  5      nU(       d  gU R
                  U R                  :  $ )a  
True for a validated fully-qualified domain nam (FQDN), in full
compliance with RFC 1035, and the "preferred form" specified in RFC
3686 s. 2, whether relative or absolute.

https://tools.ietf.org/html/rfc3696#section-2
https://tools.ietf.org/html/rfc1035

If and only if the FQDN ends with a dot (in place of the RFC1035
trailing null byte), it may have a total length of 254 bytes, still it
must be less than 253 bytes.
.      F)lenr   endswithr-   matchlabels_countr   )r   length
regex_passs      r   is_validFQDN.is_valid@   sn     TZZ::s##aKFC<[[&&tzz2
  D$4$444r   c                     U R                   S   S:H  nU R                   R                  S5      U(       a  S-   nU$ S-   nU$ )Nr0   r   r1   )r   count)r   has_terminal_dotr=   s      r   r6   FQDN.labels_countY   sG    ::b>S0

  %.>F EFFr   c                 ^    U R                   R                  S5      =(       a    U R                  $ )z
True for a fully-qualified domain name (FQDN) that is RFC
preferred-form compliant and ends with a `.`.

With relative FQDNS in DNS lookups, the current hosts domain name or
search domains may be appended.
r0   r   r4   r9   r"   s    r   is_valid_absoluteFQDN.is_valid_absolute_   s"     zz""3'9DMM9r   c                 h    U R                   R                  S5      (       + =(       a    U R                  $ )zz
True for a validated fully-qualified domain name that compiles with the
RFC preferred-form and does not ends with a `.`.
r0   rA   r"   s    r   is_valid_relativeFQDN.is_valid_relativej   s%     ::&&s++==r   c                     U R                   (       d$  [        SR                  U R                  5      5      eU R                  (       a  U R                  $ SR                  U R                  5      $ )r    invalid FQDN `{0}`z{0}.r9   r   r   r   rB   r"   s    r   r!   FQDN.absoluter   sL    
 }}188DEE!!::}}TZZ((r   c                     U R                   (       d$  [        SR                  U R                  5      5      eU R                  (       a  U R                  SS $ U R                  $ )z'
The FQDN as a string in relative form
rH   Nr<   rI   r"   s    r   relativeFQDN.relative   sI    
 }}188DEE!!::cr?"zzr   c                 `    [        U[        5      (       a  U R                  UR                  :H  $ g r&   )r   r   r!   )r   others     r   __eq__FQDN.__eq__   s'    eT""==ENN22 #r   c                 D    [        U R                  5      [        S5      -   $ )Nr   )hashr!   r"   s    r   __hash__FQDN.__hash__   s    DMM"T&\11r   )r   r   r   N)__name__
__module____qualname____firstlineno____doc__r'   r(   r   r#   propertyr-   r   r9   r6   rB   rE   r!   rL   rP   rT   __static_attributes__ r   r   r   r      s    . 	L # 	N 7 3 3 5 50  
 : : > > 
) 
) 
 
32r   r   )r)   fqdn._compatr   r   r]   r   r   <module>r_      s    	 (K2 K2r   