
    ]j'                     *   d 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edee   deez  dz  dej2                  dz  def
dZdedeee   ee   f   fdZ	 ddedee   deez  dz  dedej2                  dz  deee   ee   f   fdZ	 ddedee   deez  dz  dedej2                  dz  deee   ee   f   fdZ y)z=tldextract helpers for testing and fetching remote resources.    N)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__     @/root/env/lib/python3.12/site-packages/tldextract/suffix_list.pyr
   r
      s    r   r
   cacheurlscache_fetch_timeoutsessionreturnc                    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)r   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
   )r   r   r   r   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suffix_list_textc                    | 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)r&   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fallback_to_snapshotc           
      D    | j                  t        d| ||||dddg      S ))Fetch, parse, and cache the suffix lists.zpublicsuffix.org-tldsr   r   r   r5   r   r   r5   )func	namespacekwargshashed_argnames)run_and_cache_get_suffix_listsr8   s        r   get_suffix_listsr?   I   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)r7   )r   r   r   z.tld_set_snapshotzutf-8N)r%   r
   pkgutilget_datar   bytesdecoder4   )r   r   r   r5   r   textexcmaybe_pkg_datapkg_datar2   r3   s              r   r>   r>   _   s    "4-@'
 !>d CK$$  $--l<OPNE>2H??7+DI s   # 	A2<A--A2)NN)N)!r   loggingrA   recollections.abcr   typingr   r   requests_filer   r   r   	getLoggerr"   compileUNICODE	MULTILINEr+   r*   LookupErrorr
   strfloatintr   r%   tuplelistr4   boolr?   r>   r   r   r   <module>rY      s   C   	 $   % g%2::;RZZ",,=VW "B   /3'+	
3- t+ $	
 	D%C %E$s)TRUYBV<W %  (,
3- t+ 	
 $ 49d3i 6 (,%%
3-% t+% 	%
 $% 49d3i %r   