
    $$}gs                         d dl Z d dlmZ d dlmZmZmZmZ d dl	m
Z
 ddlmZmZ ddlmZ dZd	Zd
ZdZ e j        e          Z G d de          Z G d de          ZdS )    N)open)Dict	ItemsViewOptionalUnion)urlopen   )TldImproperlyConfigured
TldIOError)project_dirzArtur Barseghyanz2013-2023 Artur Barseghyanz,MPL-1.1 OR GPL-2.0-only OR LGPL-2.1-or-later)BaseTLDSourceParserRegistryc            	           e Zd ZU i Zeedf         ed<   d Zedefd            Z	e
dd            Ze
	 dded	dded
         fd            Ze
deedf         fd            ZdS )r   r   REGISTRYc                     t                               | |||          }t          |dd           r|| j        |j        <   |S )N_uid)type__new__getattrr   r   )mcsnamebasesattrsnew_clss        H/var/www/py-google-trends/myenv/lib/python3.11/site-packages/tld/base.pyr   zRegistry.__new__   sB    ,,sD%77 7FD)) 	1)0CL&    returnc                 .    t          | d| j                  S )Nuid)r   __name__clss    r   r   zRegistry._uid    s    sE3<000r   Nc                     i | _         d S N)r   r   s    r   resetzRegistry.reset$   s    r   keydefault)r   Nc                 8    | j                             ||          S r$   )r   get)r   r'   r(   s      r   r*   zRegistry.get(   s     |W---r   c                 4    | j                                         S r$   )r   itemsr%   s    r   r,   zRegistry.items.   s    |!!###r   )r   Nr$   )r    
__module____qualname__r   r   str__annotations__r   propertyr   classmethodr&   r   r*   r   r,    r   r   r   r      s         13Hd3--.333   1S 1 1 1 X1    [ 8<. .. 5.	*	+. . . [.
 $i%: :; $ $ $ [$ $ $r   r   c                       e Zd ZU dZdZee         ed<   eed<   eed<   dZe	ed<   e
d             Ze
dde	defd            Ze
dde	de	fd            ZdS )r   zBase TLD source parser.Nr   
source_url
local_pathTinclude_privatec                 2    | j         st          d          dS )zConstructor.z=The `uid` property of the TLD source parser shall be defined.N)r   r
   r!   s    r   validatezBaseTLDSourceParser.validateC   s-     w 	)O  	 	r   Fr   fail_silentlyretry_countc                 H    |                                   t          d          )zcGet tld names.

        :param fail_silently:
        :param retry_count:
        :return:
        z>Your TLD source parser shall implement `get_tld_names` method.)r9   NotImplementedError)r"   r:   r;   s      r   get_tld_namesz!BaseTLDSourceParser.get_tld_namesK   s&     	!L
 
 	
r   r   c           	      D   	 t          | j                  }t          | j                  }t	          |dd          }|                    |                                                    d                     |                                 |                                 t          
                    d| j         d| d           n[# t          $ rN}t                              d| j         dt          |                      |rY d	}~d
S t          |          d	}~ww xY wdS )z_Update the local copy of the TLD file.

        :param fail_silently:
        :return:
        wbutf8)encodingz	Fetched 'z' as ''zFailed fetching 'z'. Reason: NFT)r   r5   r   r6   codecs_openwritereaddecodecloseLOGGERinfo	Exceptionerrorr/   r   )r"   r:   remote_filelocal_file_abs_path
local_fileerrs         r   update_tld_namesz$BaseTLDSourceParser.update_tld_namesX   s=   	"!#.11K"-cn"="=$%8$PPPJ[--//66v>>???KKHCNHH2EHHH     	" 	" 	"LLICNIIs3xxII    uuuuuS//!	" ts   CC 
D4D	DD)Fr   )F)r    r-   r.   __doc__r   r   r/   r0   r7   boolr2   r9   intr>   rQ   r3   r   r   r   r   ;   s         !!C#OOOOOO OT     [ 

 

$ 

S 

 

 

 [

  T d    [  r   r   )	metaclass)loggingcodecsr   rD   typingr   r   r   r   urllib.requestr   
exceptionsr
   r   helpersr   
__author____copyright____license____all__	getLoggerr    rI   r   r   r   r3   r   r   <module>ra      s    & & & & & & 3 3 3 3 3 3 3 3 3 3 3 3 " " " " " " ; ; ; ; ; ; ; ;            
,<
 
	8	$	$$ $ $ $ $t $ $ $N6 6 6 6 6H 6 6 6 6 6 6r   