
    hk                    b   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
Z
ddlmZ ddlmZ  ej                  d	      Z ej"                  d
ej$                  ej&                  z        ZdZ G d de      Z	 	 d	 	 	 	 	 	 	 	 	 ddZddZ	 d	 	 	 	 	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 	 	 	 	 	 	 ddZy)z=tldextract helpers for testing and fetching remote resources.    )annotationsN)Sequence)cast)FileAdapter   )	DiskCache
tldextractz^(?P<suffix>[.*!]*\w[\S]*)z// ===BEGIN PRIVATE DOMAINS===c                      e Zd ZdZy)SuffixListNotFoundzA recoverable error while looking up a suffix list.

    Recoverable because you can specify backups, or use this library's bundled
    snapshot.
    N)__name__
__module____qualname____doc__     Y/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/tldextract/suffix_list.pyr   r      s    r   r   c                   d}|0t        j                         }|j                  dt                      d}	 |D ]+  }	 | j	                  |||      c |r|j                          S S  	 |r|j                          t        d      t        d      # t         j                  j                  $ r t        j                  d|d       Y w xY w# |r|j                          w w xY w)zQDecode the first successfully fetched URL, from UTF-8 encoding to Python unicode.Fzfile://T)sessionurltimeoutz+Exception reading Public Suffix List url %s)exc_infozNo remote Public Suffix List found. Consider using a mirror, or avoid this fetch by constructing your TLDExtract with `suffix_list_urls=()`.)requestsSessionmountr   cached_fetch_urlclose
exceptionsRequestExceptionLOGwarningr   )cacheurlscache_fetch_timeoutr   session_createdr   s         r   find_first_responser%      s     O""$i/ 	C--#6I .   MMO 	 MMO
	M 
	M  &&77 A3QU   MMO s4   C
 BC
 %C
 5CC
 CC
 
Cc                   | j                  t              \  }}}t        j                  |      D cg c]  }|j	                  d       }}t        j                  |      D cg c]  }|j	                  d       }}||fS c c}w c c}w )zJParse the raw suffix list text for its different designations of suffixes.suffix)	partitionPUBLIC_PRIVATE_SUFFIX_SEPARATORPUBLIC_SUFFIX_REfinditergroup)suffix_list_textpublic_text_private_textmpublic_tldsprivate_tldss          r   extract_tlds_from_suffix_listr4   @   s    #3#=#='$ KL /?.G.G.TU1778$UKU/?/H/H/VW!AGGH%WLW$$ VWs   B "Bc           
     D    | j                  t        d| ||||dddg      S ))Fetch, parse, and cache the suffix lists.zpublicsuffix.org-tldsr!   r"   r#   fallback_to_snapshotr   r"   r8   )func	namespacekwargshashed_argnames)run_and_cache_get_suffix_listsr7   s        r   get_suffix_listsr?   K   sA     )#6$8
  !78   r   c                    	 t        | |||      }t        |      \  }	}
|	|
fS # t        $ rF}|r8t        j                  dd      }t	        t
        |      }|j                  d      }n|Y d}~\d}~ww xY w)r6   )r#   r   r	   z.tld_set_snapshotzutf-8N)r%   r   pkgutilget_datar   bytesdecoder4   )r!   r"   r#   r8   r   textexcmaybe_pkg_datapkg_datar2   r3   s              r   r>   r>   a   s    "4-@'
 !>d CK$$  $--l<OPNE>2H??7+DI s   # 	A2<A--A2)NN)
r!   r   r"   Sequence[str]r#   float | int | Noner   requests.Session | Nonereturnstr)r-   rM   rL   tuple[list[str], list[str]])N)r!   r   r"   rI   r#   rJ   r8   boolr   rK   rL   rN   )r   
__future__r   loggingrA   recollections.abcr   typingr   r   requests_filer   r!   r   	getLoggerr   compileUNICODE	MULTILINEr*   r)   LookupErrorr   r%   r4   r?   r>   r   r   r   <module>r[      s-   C "   	 $   % g%2::;RZZ",,=VW "B   /3'+	
 , %	
 	D%  (,
 , 	
 % !6 (,%%
% ,% 	%
 %% !%r   