
    ]jr                         d Z ddlZddlmZmZ ddlmZ  ej                  dej                        Z	 e
e      ZdedefdZdedefd	Zd
edefdZd
edefdZy)z=tldextract helpers for testing and fetching remote resources.    N)AddressValueErrorIPv6Address)scheme_charszo^(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$urlreturnc                 h   t        |       j                  d      d   j                  d      d   j                  d      d   j                  d      d   }|r)|d   dk(  r!|j                  d      }|d	   dk(  r|d    dS |j                  d
      d   j                         }|j	                  d      }|S )zExtract the netloc of a URL-like string.

    Similar to the netloc attribute returned by
    urllib.parse.{urlparse,urlsplit}, but extract more leniently, without
    raising errors.
    /r   ?#@[]   :u
   .。．｡)_schemeless_url	partition
rpartitionstriprstrip)r   after_userinfo
maybe_ipv6hostnamewithout_root_labels        ;/root/env/lib/python3.12/site-packages/tldextract/remote.pylenient_netlocr      s     		3		3	 
3	 
C		  .+s2#--c2
a=C m_A&&'',Q/557H!)>?    c                     | j                  d      }|dk(  r| dd  S |dk  s#| |dz
     dk7  st        | d |dz
         t        z
  r| S | |dz   d  S )Nz//r      r   r   )findsetscheme_chars_set)r   double_slashes_starts     r   r   r   )   ss    88D>q 12wq #a'(C/s-)A-./2BB
#a')**r   maybe_ipc                 X    | d   j                         syt        j                  |       duS )z7Check whether the given str looks like an IPv4 address.r   FN)	isdecimalIP_RE	fullmatchr$   s    r   looks_like_ipr*   6   s)    A;  "??8$D00r   c                 :    	 t        |        y# t        $ r Y yw xY w)z7Check whether the given str looks like an IPv6 address.FT)r   r   r)   s    r   looks_like_ipv6r,   >   s(    H   s    	)__doc__re	ipaddressr   r   urllib.parser   compileASCIIr'   r!   r"   strr   r   boolr*   r,    r   r   <module>r6      s    C 	 4 %

>HH	 |$   2
+ 
+ 
+1C 1D 1c d r   