
    %bB                         d Z ddlZddlZddlZddl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	Zd
 Zd Zd ZdS )z=tldextract helpers for testing and fetching remote resources.    N)FileAdapter
tldextractz^(?P<suffix>[.*!]*\w[\S]*)z// ===BEGIN PRIVATE DOMAINS===c                       e Zd ZdZdS )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__     6lib/python3.11/site-packages/tldextract/suffix_list.pyr   r      s"        H H H Hr   r   c                 |   t          j                    5 }|                    dt                                 |D ]]}	 |                     |||          c cddd           S # t           j        j        $ r t                              d|           Y Zw xY w	 ddd           n# 1 swxY w Y   t          d          )zZDecode the first successfully fetched URL, from UTF-8 encoding to
    Python unicode.
    zfile://)sessionurltimeoutNz+Exception reading Public Suffix List url %szrNo Public Suffix List found. Consider using a mirror or constructing your TLDExtract with `suffix_list_urls=None`.)
requestsSessionmountr   cached_fetch_url
exceptionsRequestExceptionLOG	exceptionr   )cacheurlscache_fetch_timeoutr   r   s        r   find_first_responser      s_    
			 	Rwi/// 	R 	RCR--#6I .    	R 	R 	R 	R 	R 	R 	R 	R &7 R R RKSQQQQQR	R	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	8  s4   'B$A"B$"/BB$BB$$B(+B(c                     |                      t                    \  }}}d t                              |          D             }d t                              |          D             }||fS )zNParse the raw suffix list text for its different designations of
    suffixes.c                 8    g | ]}|                     d           S suffixgroup.0ms     r   
<listcomp>z1extract_tlds_from_suffix_list.<locals>.<listcomp>0   s$    UUU1778$$UUUr   c                 8    g | ]}|                     d           S r    r"   r$   s     r   r'   z1extract_tlds_from_suffix_list.<locals>.<listcomp>1   s$    WWW!AGGH%%WWWr   )	partitionPUBLIC_PRIVATE_SUFFIX_SEPARATORPUBLIC_SUFFIX_REfinditer)suffix_list_textpublic_text_private_textpublic_tldsprivate_tldss         r   extract_tlds_from_suffix_listr3   )   su     $4#=#='$ $ KL VU.>.G.G.T.TUUUKWW/?/H/H/V/VWWWL$$r   c           	      L    |                      t          d| |||dddg          S )(Fetch, parse, and cache the suffix listszpublicsuffix.org-tldsr   r   r   fallback_to_snapshotr   r7   )func	namespacekwargshashed_argnames)run_and_cache_get_suffix_listsr6   s       r   get_suffix_listsr>   5   sF    )#6$8	
 
  !78  
 
 
r   c                    	 t          | ||          }nV# t          $ rI}|r;t          j        dd          }t	          |t
                    st          |d          }n|Y d}~nd}~ww xY wt          |          \  }}||fS )r5   )r   r   z.tld_set_snapshotzutf-8N)r   r   pkgutilget_data
isinstancestrr3   )r   r   r   r7   textexcr1   r2   s           r   r=   r=   D   s    "5$DWXXX    	#L2EFFDdC(( *4))I !>d C CK$$s    
A(?A##A()N)r
   loggingr@   rer   requests_filer   	getLoggerr   compileUNICODE	MULTILINEr+   r*   LookupErrorr   r   r3   r>   r=   r   r   r   <module>rN      s    ? ?   				  % % % % % %g%%2:;RZ",=VWW "B H H H H H H H H
   (	% 	% 	%  % % % % %r   