o
     JAfR                     @   s  	 d a dd lZdd lZdd lZdd lZdd lZejdkZer'dd lZ	dd l
Z
ndd lZ	er2ddgZndgZed ZeeZdeZdd eD ZdZd	Zee Zd
d Ze Zdd Zdd Zdd Zerkdd Zndd Zdd Zdd Zdd Zdd Zdd Zerdd  Z nd!d  Z dmd#d$Z!e"e!j#Z$d%%d&d'd( Z&e'(e&d'Z)d)Z*d*Z+d+gZ,ere,-d, e. Z/d-gZ0e0 Z1Z2dnd d.d/d0Z3d1d2 Z4d3d4 Z5d5d6 Z6d7d8 Z7d9d: Z8d;d< Z9d=d> Z:d?d@ Z;dAdB Z<dodCdDZ=dpdEdFZ>dqdHdIZ?dJdK Z@eA ZBdnd eBdLdMdNZCG dOdP dPZDG dQdR dRZEG dSdT dTeEZFG dUdV dVZGG dWdX dXeGeFZHG dYdZ dZeGeEZIG d[d\ d\eGeEZJG d]d^ d^ZKG d_d` d`ZLG dadb dbZMG dcdd ddZNdndedfZOdgdh ZPdidj ZQdkdl ZRd S )rN    win32\/ c                 C   s   h | ]}d | qS ): ).0sr   r   4/usr/lib/python3.10/importlib/_bootstrap_external.py	<setcomp>2   s    r   )win)cygwindarwinc                     s>   t jtrt jtrd nd  fdd} | S dd } | S )NPYTHONCASEOKs   PYTHONCASEOKc                      s   	 t jj o
 tjv S N)sysflagsignore_environment_osenvironr   keyr   r
   _relax_caseC      z%_make_relax_case.<locals>._relax_casec                   S   s   	 dS )NFr   r   r   r   r
   r   G      )r   platform
startswith_CASE_INSENSITIVE_PLATFORMS#_CASE_INSENSITIVE_PLATFORMS_STR_KEY)r   r   r   r
   _make_relax_case<   s   r   c                 C   s   	 t | d@ ddS )N       little)intto_bytes)xr   r   r
   _pack_uint32O   r   r&   c                 C      	 t | dS Nr"   r#   
from_bytesdatar   r   r
   _unpack_uint32T      r-   c                 C   r'   r(   r)   r+   r   r   r
   _unpack_uint16Y   r.   r/   c                  G   s   	 | sdS t | dkr| d S d}g }ttj| D ]=\}}|ts'|tr4|tp-|}t	| g}q|drM|
 |
 krG|}|g}q|| q|pP|}|| qdd |D }t |dkrl|d sl|t	 S |t	| S )Nr      r   r   c                 S      g | ]	}|r| tqS r   rstrippath_separatorsr   pr   r   r
   
<listcomp>w   s    _path_join.<locals>.<listcomp>)lenmapr   _path_splitrootr   path_sep_tupleendswithr3   r4   path_sepcasefoldappendjoin)
path_partsrootpathZnew_roottailr   r   r
   
_path_join`   s,   
rF   c                  G   s   	 t dd | D S )Nc                 S   r1   r   r2   )r   partr   r   r
   r7      s    r8   )r>   rA   )rB   r   r   r
   rF   ~   s   
c                    sD   	 t  fddtD }|dk rd fS  d |  |d d  fS )Nc                 3   s    | ]}  |V  qd S r   )rfindr5   rD   r   r
   	<genexpr>   s    z_path_split.<locals>.<genexpr>r   r   r0   )maxr4   )rD   ir   rI   r
   _path_split   s
   rM   c                 C   s   	 t | S r   )r   statrI   r   r   r
   
_path_stat   s   
rO   c                 C   s2   	 zt | }W n
 ty   Y dS w |jd@ |kS )NFi   )rO   OSErrorst_mode)rD   mode	stat_infor   r   r
   _path_is_mode_type   s   rT   c                 C   s   	 t | dS )Ni   )rT   rI   r   r   r
   _path_isfile      
rU   c                 C   s   	 | st  } t| dS )Ni @  )r   getcwdrT   rI   r   r   r
   _path_isdir   s   
rX   c                 C   s@   	 | sdS t | d dd}t|dko|dp|dS )NFr   r   r   r0   z\\)r   r;   replacer9   r   r=   )rD   rC   r   r   r
   _path_isabs   s
    rZ   c                 C   s   	 |  tS r   )r   r4   rI   r   r   r
   rZ      rV     c                 C   s   	 d | t| }t|tjtjB tjB |d@ }z$t|d}|	| W d    n1 s0w   Y  t
||  W d S  tyU   zt| W   tyT   Y  w w )N{}.{}r[   wb)formatidr   openO_EXCLO_CREATO_WRONLY_ioFileIOwriterY   rP   unlink)rD   r,   rR   path_tmpfdfiler   r   r
   _write_atomic   s&   rk   io     r"   s   
__pycache__zopt-z.pyz.pywz.pyc)optimizationc                C   sR  	 |d urt dt |d urd}t||rdnd}t| } t| \}}|d\}}}tj	j
}	|	d u r:tdd|r@|n|||	g}
|d u rWtjjdkrSd}ntjj}t|}|dkrq| sjtd|d	|
t|}
|
td  }tjd urt|stt |}|d d
kr|d tvr|dd  }ttj|t|S t|t|S )NzFthe debug_override parameter is deprecated; use 'optimization' insteadz2debug_override or optimization must be set to Noner   r0   .$sys.implementation.cache_tag is Noner   z{!r} is not alphanumericz{}.{}{}r   rl   )	_warningswarnDeprecationWarning	TypeErrorr   fspathrM   
rpartitionr   implementation	cache_tagNotImplementedErrorrA   r   optimizestrisalnum
ValueErrorr^   _OPTBYTECODE_SUFFIXESpycache_prefixrZ   rF   rW   r4   lstrip_PYCACHE)rD   debug_overridern   messageheadrE   basesepresttagalmost_filenamefilenamer   r   r
   cache_from_source|  sJ   

	r   c           
      C   s*  	 t jjd u rtdt| } t| \}}d}t jd ur4t jt	}|
|t r4|t|d  }d}|sIt|\}}|tkrItt d| |d}|dvrYtd||dkr|dd	d
 }|
tsqtdt|ttd  }| std|d|dd }	t||	td  S )Nrp   FTz not bottom-level directory in ro   >   rl      zexpected only 2 or 3 dots in r   rl   z5optimization portion of filename does not start with zoptimization level z is not an alphanumeric valuer   )r   rw   rx   ry   r   ru   rM   r   r3   r4   r   r>   r9   r   r}   countrsplitr~   r|   	partitionrF   SOURCE_SUFFIXES)
rD   r   pycache_filenamefound_in_pycache_prefixstripped_pathpycache	dot_countrn   	opt_levelbase_filenamer   r   r
   source_from_cache  s>   



r   c              	   C   s~   	 t | dkr	d S | d\}}}|r| dd dkr| S zt| }W n ttfy6   | d d }Y nw t|r=|S | S )Nr   ro   py)r9   rv   lowerr   ry   r}   rU   )bytecode_pathr   _	extensionsource_pathr   r   r
   _get_sourcefile  s   r   c                 C   sD   |  ttrzt| W S  ty   Y d S w |  ttr | S d S r   )r=   tupler   r   ry   r   )r   r   r   r
   _get_cached  s   
r   c                 C   s4   	 zt | j}W n ty   d}Y nw |dO }|S )Nr[      )rO   rQ   rP   )rD   rR   r   r   r
   
_calc_mode
  s   r   c                    s6   	 d fdd	}t d urt j}ndd }||  |S )Nc                    sH   |d u r| j }n| j |krtd| j |f |d | |g|R i |S )Nzloader for %s cannot handle %sname)r   ImportError)selfr   argskwargsmethodr   r
   _check_name_wrapper  s   
z(_check_name.<locals>._check_name_wrapperc                 S   s8   dD ]}t ||rt| |t|| q| j|j d S )N)
__module____name____qualname____doc__)hasattrsetattrgetattr__dict__update)newoldrY   r   r   r
   _wrap+  s
   
z_check_name.<locals>._wrapr   )
_bootstrapr   )r   r   r   r   r   r
   _check_name  s   

r   c                 C   sJ   	 t dt | |\}}|d u r#t|r#d}t ||d t |S )NzZfind_module() is deprecated and slated for removal in Python 3.12; use find_spec() insteadz,Not importing directory {}: missing __init__r   )rq   rr   rs   find_loaderr9   r^   ImportWarning)r   fullnameloaderportionsmsgr   r   r
   _find_module_shim5  s   r   c                 C   s   	 | d d }|t kr!d|d|}td| t|fi |t| dk r6d|}td| t|t| dd }|d@ rRd	|d
|}t|fi ||S )Nr!   zbad magic number in z: {}   z(reached EOF while reading pyc header of    zinvalid flags z in )MAGIC_NUMBERr   _verbose_messager   r9   EOFErrorr-   )r,   r   exc_detailsmagicr   r   r   r   r
   _classify_pycI  s   
r   c                 C   s~   	 t | dd |d@ kr d|}td| t|fi ||d ur;t | dd |d@ kr=td|fi |d S d S )Nr      r    zbytecode is stale for r   r   )r-   r   r   r   )r,   source_mtimesource_sizer   r   r   r   r   r
   _validate_timestamp_pycj  s   
r   c                 C   s,   	 | dd |krt d|fi |d S )Nr   r   z.hash in bytecode doesn't match hash of source )r   )r,   source_hashr   r   r   r   r
   _validate_hash_pyc  s   r   c                 C   sN   	 t | }t|trtd| |d urt|| |S td	|||d)Nzcode object from {!r}zNon-code object in {!r}r   rD   )
marshalloads
isinstance
_code_typer   r   _imp_fix_co_filenamer   r^   )r,   r   r   r   coder   r   r
   _compile_bytecode  s   


r   c                 C   sH   	 t t}|td |t| |t| |t|  |S )Nr   	bytearrayr   extendr&   r   dumps)r   mtimer   r,   r   r   r
   _code_to_timestamp_pyc  s   r   Tc                 C   sB   	 t t}d|d> B }|t| || |t|  |S )Nr0   r   )r   r   checkedr,   r   r   r   r
   _code_to_hash_pyc  s   
r   c                 C   s@   	 dd l }t| j}||}td d}|| |d S )Nr   T)tokenizerd   BytesIOreadlinedetect_encodingIncrementalNewlineDecoderdecode)source_bytesr   source_bytes_readlineencodingnewline_decoderr   r   r
   decode_source  s   
r   r   submodule_search_locationsc          	      C   s8  	 |d u rd}t |drz|| }W n& ty   Y nw nt|}t|s:z	tt |}W n	 ty9   Y nw t	j
| ||d}d|_|d u rdt D ]\}}|t|ra|| |}||_ nqLd S |tu rt |drz|| }W n	 ty}   Y n
w |rg |_n||_|jg kr|rt|d }|j| |S )Nz	<unknown>get_filenameoriginT
is_packager   )r   r   r   r   ru   rZ   rF   rW   rP   r   
ModuleSpec_set_fileattr_get_supported_file_loadersr=   r   r   	_POPULATEr   r   rM   r@   )	r   locationr   r   specloader_classsuffixesr   dirnamer   r   r
   spec_from_file_location  sV   


	


r  c                   @   sV   e Zd Z	 dZdZeodev Zedd Z	e
dd Ze
dd	d
Ze
dddZdS )WindowsRegistryFinderz;Software\Python\PythonCore\{sys_version}\Modules\{fullname}zASoftware\Python\PythonCore\{sys_version}\Modules\{fullname}\Debugz_d.pydc                 C   s2   zt t j| W S  ty   t t j|  Y S w r   )winregOpenKeyHKEY_CURRENT_USERrP   HKEY_LOCAL_MACHINEr   r   r   r
   _open_registry&  s
   z$WindowsRegistryFinder._open_registryc                 C   s   | j r| j}n| j}|j|dtjd d  d}z | |}t|d}W d    W |S 1 s1w   Y  W |S  t	yB   Y d S w )Nz%d.%drl   )r   sys_versionr   )
DEBUG_BUILDREGISTRY_KEY_DEBUGREGISTRY_KEYr^   r   version_infor  r  
QueryValuerP   )clsr   registry_keyr   hkeyfilepathr   r   r
   _search_registry-  s    z&WindowsRegistryFinder._search_registryNc                 C   sx   |  |}|d u rd S zt| W n
 ty   Y d S w t D ]\}}|t|r9tj|||||d}|  S qd S )Nr   )r  rO   rP   r   r=   r   r   spec_from_loader)r  r   rD   targetr  r   r   r   r   r   r
   	find_spec<  s"   
zWindowsRegistryFinder.find_specc                 C   s,   	 t dt | ||}|d ur|jS d S )NzpWindowsRegistryFinder.find_module() is deprecated and slated for removal in Python 3.12; use find_spec() insteadrq   rr   rs   r  r   r  r   rD   r   r   r   r
   find_moduleL  s   z!WindowsRegistryFinder.find_moduleNNr   )r   r   r   r  r
  _MS_WINDOWSEXTENSION_SUFFIXESr	  staticmethodr  classmethodr  r  r  r   r   r   r
   r    s    

r  c                   @   s.   e Zd Z	 dd Zdd Zdd Zdd Zd	S )
_LoaderBasicsc                 C   sB   	 t | |d }|ddd }|dd }|dko |dkS )Nr0   ro   r   rl   __init__)rM   r   r   rv   )r   r   r   filename_base	tail_namer   r   r
   r   b  s
   z_LoaderBasics.is_packagec                 C      d S r   r   r   r   r   r   r
   create_modulej     z_LoaderBasics.create_modulec                 C   s:   	 |  |j}|d u rtd|jtt||j d S )Nz4cannot load module {!r} when get_code() returns None)get_coder   r   r^   r   _call_with_frames_removedexecr   )r   moduler   r   r   r
   exec_modulem  s   z_LoaderBasics.exec_modulec                 C   s   	 t | |S r   )r   _load_module_shimr   r   r   r   r
   load_moduleu  r.   z_LoaderBasics.load_moduleN)r   r   r   r   r$  r*  r-  r   r   r   r
   r  ]  s    r  c                   @   sJ   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZddddZdd Z	dS )SourceLoaderc                 C   s   	 t r   )rP   r   rD   r   r   r
   
path_mtime}  s   zSourceLoader.path_mtimec                 C   s   	 d|  |iS )Nr   )r0  r/  r   r   r
   
path_stats  s   zSourceLoader.path_statsc                 C   s   	 |  ||S r   )set_data)r   r   
cache_pathr,   r   r   r
   _cache_bytecode  s   zSourceLoader._cache_bytecodec                 C   r"  r   r   )r   rD   r,   r   r   r
   r2    r%  zSourceLoader.set_datac              
   C   sH   	 |  |}z
| |}W t|S  ty# } ztd|d|d }~ww )Nz'source not available through get_data()r   )r   get_datarP   r   r   )r   r   rD   r   excr   r   r
   
get_source  s   
zSourceLoader.get_sourcer   )	_optimizec                C   s   	 t jt||dd|dS )Nr(  T)dont_inheritrz   )r   r'  compile)r   r,   rD   r8  r   r   r
   source_to_code  s   zSourceLoader.source_to_codec              	   C   s  	 |  |}d }d }d }d}d}zt|}W n ty!   d }Y nw z| |}	W n	 ty2   Y nw t|	d }z| |}
W n	 tyI   Y nhw ||d}zGt|
||}t|
dd  }|d@ dk}|r|d@ dk}t	j
d	kr|sxt	j
d
kr| |}t	t|}t|
||| n
t|
||	d || W n ttfy   Y nw td|| t||||dS |d u r| |}| ||}td| tjs|d ur|d ur|r|d u rt	|}t|||}
nt||t|}
z
| |||
 W |S  ty   Y |S w |S )NFTr   r   r   r0   r   rl   neveralwayssizez{} matches {})r   r   r   zcode object from {})r   r   ry   r1  rP   r#   r5  r   
memoryviewr   check_hash_based_pycsr   _RAW_MAGIC_NUMBERr   r   r   r   r   r   r   r;  r   dont_write_bytecoder   r   r9   r4  )r   r   r   r   r   r   
hash_basedcheck_sourcer   str,   r   r   
bytes_datacode_objectr   r   r
   r&    s   






zSourceLoader.get_codeN)
r   r   r   r0  r1  r4  r2  r7  r;  r&  r   r   r   r
   r.  {  s    

r.  c                       sZ   e Zd Z	 dd Zdd Zdd Ze fddZed	d
 Zdd Z	edd Z
  ZS )
FileLoaderc                 C   s   	 || _ || _d S r   r   )r   r   rD   r   r   r
   r    s   
zFileLoader.__init__c                 C      | j |j ko| j|jkS r   	__class__r   r   otherr   r   r
   __eq__     
zFileLoader.__eq__c                 C      t | jt | jA S r   hashr   rD   r   r   r   r
   __hash__     zFileLoader.__hash__c                    s   	 t t| |S r   )superrH  r-  r,  rK  r   r
   r-    s   zFileLoader.load_modulec                 C      	 | j S r   rI   r,  r   r   r
   r   )     zFileLoader.get_filenamec                 C   s   	 t | ttfr%tt|}| W  d    S 1 sw   Y  d S t|d}| W  d    S 1 s:w   Y  d S )Nr)r   r.  ExtensionFileLoaderrd   	open_coder{   readre   )r   rD   rj   r   r   r
   r5  .  s   $$zFileLoader.get_datac                 C   s   ddl m} || S )Nr   )
FileReader)importlib.readersr^  )r   r)  r^  r   r   r
   get_resource_reader7  s   zFileLoader.get_resource_reader)r   r   r   r  rN  rT  r   r-  r   r5  r`  __classcell__r   r   rW  r
   rH    s    
	rH  c                   @   s,   e Zd Z	 dd Zdd ZddddZd	S )
SourceFileLoaderc                 C   s   	 t |}|j|jdS )N)r   r>  )rO   st_mtimest_size)r   rD   rE  r   r   r
   r1  A  s   zSourceFileLoader.path_statsc                 C   s   t |}| j|||dS )N_mode)r   r2  )r   r   r   r,   rR   r   r   r
   r4  F  s   z SourceFileLoader._cache_bytecoder[   re  c          	      C   s   	 t |\}}g }|r t|s t |\}}|| |r t|rt|D ]1}t||}zt| W q$ ty;   Y q$ tyU } zt	
d|| W Y d }~ d S d }~ww zt||| t	
d| W d S  ty } zt	
d|| W Y d }~d S d }~ww )Nzcould not create {!r}: {!r}zcreated {!r})rM   rX   r@   reversedrF   r   mkdirFileExistsErrorrP   r   r   rk   )	r   rD   r,   rf  parentr   rB   rG   r6  r   r   r
   r2  K  s:   

zSourceFileLoader.set_dataN)r   r   r   r1  r4  r2  r   r   r   r
   rb  =  s
    rb  c                   @   s   e Zd Z	 dd Zdd ZdS )SourcelessFileLoaderc                 C   sD   |  |}| |}||d}t||| tt|dd  ||dS )Nr   r   )r   r   )r   r5  r   r   r?  )r   r   rD   r,   r   r   r   r
   r&  n  s   

zSourcelessFileLoader.get_codec                 C      	 d S r   r   r,  r   r   r
   r7  ~  r   zSourcelessFileLoader.get_sourceN)r   r   r   r&  r7  r   r   r   r
   rk  j  s    rk  c                   @   sZ   e Zd Z	 dd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
edd ZdS )r[  c                 C   s   || _ || _d S r   r   )r   r   rD   r   r   r
   r    s   
zExtensionFileLoader.__init__c                 C   rI  r   rJ  rL  r   r   r
   rN    rO  zExtensionFileLoader.__eq__c                 C   rP  r   rQ  rS  r   r   r
   rT    rU  zExtensionFileLoader.__hash__c                 C   s&   	 t tj|}t d|j| j |S )Nz&extension module {!r} loaded from {!r})r   r'  r   create_dynamicr   r   rD   )r   r   r)  r   r   r
   r$    s   z!ExtensionFileLoader.create_modulec                 C   s&   	 t tj| t d| j| j d S )Nz(extension module {!r} executed from {!r})r   r'  r   exec_dynamicr   r   rD   r   r)  r   r   r
   r*    s
   zExtensionFileLoader.exec_modulec                    s&   	 t | jd  t fddtD S )Nr0   c                 3   s    | ]	} d | kV  qdS )r  Nr   r   suffix	file_namer   r
   rJ     s    z1ExtensionFileLoader.is_package.<locals>.<genexpr>)rM   rD   anyr  r,  r   rr  r
   r     s
   zExtensionFileLoader.is_packagec                 C   rl  r   r   r,  r   r   r
   r&    r   zExtensionFileLoader.get_codec                 C   rl  r   r   r,  r   r   r
   r7    r   zExtensionFileLoader.get_sourcec                 C   rX  r   rI   r,  r   r   r
   r     rY  z ExtensionFileLoader.get_filenameN)r   r   r   r  rN  rT  r$  r*  r   r&  r7  r   r   r   r   r   r
   r[    s    r[  c                   @   sj   e Zd Z	 dZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd ZdS )_NamespacePathr   c                 C   s,   || _ || _t|  | _| j| _|| _d S r   )_name_pathr   _get_parent_path_last_parent_path_epoch_last_epoch_path_finderr   r   rD   path_finderr   r   r
   r    s
   
z_NamespacePath.__init__c                 C   s(   	 | j d\}}}|dkrdS |dfS )Nro   r   )r   rD   __path__)rv  rv   )r   rj  dotmer   r   r
   _find_parent_path_names  s
   z&_NamespacePath._find_parent_path_namesc                 C   s   |   \}}ttj| |S r   )r  r   r   modules)r   parent_module_namepath_attr_namer   r   r
   rx    s   z_NamespacePath._get_parent_pathc                 C   sd   t |  }|| jks| j| jkr/| | j|}|d ur(|jd u r(|jr(|j| _	|| _| j| _| j	S r   )
r   rx  ry  rz  r{  r|  rv  r   r   rw  )r   parent_pathr   r   r   r
   _recalculate  s   z_NamespacePath._recalculatec                 C      t |  S r   )iterr  rS  r   r   r
   __iter__     z_NamespacePath.__iter__c                 C   s   |   | S r   r  )r   indexr   r   r
   __getitem__  r  z_NamespacePath.__getitem__c                 C   s   || j |< d S r   )rw  )r   r  rD   r   r   r
   __setitem__  s   z_NamespacePath.__setitem__c                 C   r  r   )r9   r  rS  r   r   r
   __len__  r  z_NamespacePath.__len__c                 C      d | jS )Nz_NamespacePath({!r}))r^   rw  rS  r   r   r
   __repr__  r  z_NamespacePath.__repr__c                 C   s   ||   v S r   r  r   itemr   r   r
   __contains__  r  z_NamespacePath.__contains__c                 C   s   | j | d S r   )rw  r@   r  r   r   r
   r@        z_NamespacePath.appendN)r   r   r   rz  r  r  rx  r  r  r  r  r  r  r  r@   r   r   r   r
   ru    s    
ru  c                   @   sX   e Zd Zdd Zedd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd ZdS )_NamespaceLoaderc                 C   s   t |||| _d S r   )ru  rw  r}  r   r   r
   r    s   z_NamespaceLoader.__init__c                 C   s   	 t dt d| jS )NzR_NamespaceLoader.module_repr() is deprecated and slated for removal in Python 3.12z<module {!r} (namespace)>)rq   rr   rs   r^   r   )r)  r   r   r
   module_repr  s
   z_NamespaceLoader.module_reprc                 C      dS )NTr   r,  r   r   r
   r     r%  z_NamespaceLoader.is_packagec                 C   r  Nr   r   r,  r   r   r
   r7    r%  z_NamespaceLoader.get_sourcec                 C   s   t dddddS )Nr   z<string>r(  T)r9  )r:  r,  r   r   r
   r&    r  z_NamespaceLoader.get_codec                 C   r"  r   r   r#  r   r   r
   r$    r%  z_NamespaceLoader.create_modulec                 C   r"  r   r   ro  r   r   r
   r*    r%  z_NamespaceLoader.exec_modulec                 C   s   	 t d| j t | |S )Nz&namespace module loaded with path {!r})r   r   rw  r+  r,  r   r   r
   r-    s
   z_NamespaceLoader.load_modulec                 C   s   ddl m} || jS )Nr   )NamespaceReader)r_  r  rw  )r   r)  r  r   r   r
   r`  '  s   
z$_NamespaceLoader.get_resource_readerN)r   r   r   r  r  r  r   r7  r&  r$  r*  r-  r`  r   r   r   r
   r    s    

r  c                   @   st   e Zd Z	 edd Zedd Zedd Zedd Zedd
dZ	edddZ
edddZedd Zd	S )
PathFinderc                  C   sP   	 t tj D ]\} }|d u rtj| = qt|dr|  qt jd7  _d S )Ninvalidate_cachesr0   )listr   path_importer_cacheitemsr   r  ru  rz  )r   finderr   r   r
   r  2  s   

zPathFinder.invalidate_cachesc              	   C   sN   	 t jd urt jstdt t jD ]}z|| W   S  ty$   Y qw d S )Nzsys.path_hooks is empty)r   
path_hooksrq   rr   r   r   )rD   hookr   r   r
   _path_hooks?  s   
zPathFinder._path_hooksc                 C   sf   	 |dkrzt  }W n
 ty   Y d S w ztj| }W |S  ty2   | |}|tj|< Y |S w r  )r   rW   FileNotFoundErrorr   r  KeyErrorr  )r  rD   r  r   r   r
   _path_importer_cacheL  s   
zPathFinder._path_importer_cachec                 C   s   t |drt| d}t|t ||\}}nt| d}t|t ||}g }|d ur:t||S t	|d }||_
|S )Nr   z5.find_spec() not found; falling back to find_loader()z5.find_spec() not found; falling back to find_module())r   r   _object_namerq   rr   r   r   r  r  r   r   )r  r   r  r   r   r   r   r   r   r
   _legacy_get_specb  s   

zPathFinder._legacy_get_specNc           	      C   s   	 g }|D ]C}t |ttfsq| |}|d urHt|dr$|||}n| ||}|d u r/q|jd ur8|  S |j}|d u rCt	d|
| qt|d }||_|S )Nr  zspec missing loader)r   r{   bytesr  r   r  r  r   r   r   r   r   r   )	r  r   rD   r  namespace_pathentryr  r   r   r   r   r
   	_get_specw  s,   



zPathFinder._get_specc                 C   s`   	 |d u rt j}| |||}|d u rd S |jd u r.|j}|r,d |_t||| j|_|S d S |S r   )r   rD   r  r   r   r   ru  )r  r   rD   r  r   r  r   r   r
   r    s   
zPathFinder.find_specc                 C   s,   	 t dt | ||}|d u rd S |jS )NzePathFinder.find_module() is deprecated and slated for removal in Python 3.12; use find_spec() insteadr  r  r   r   r
   r    s   zPathFinder.find_modulec                  O   s   	 ddl m} |j| i |S )Nr   )MetadataPathFinder)importlib.metadatar  find_distributions)r   r   r  r   r   r
   r    s   zPathFinder.find_distributionsr   r  )r   r   r   r  r  r  r  r  r  r  r  r  r  r   r   r   r
   r  .  s$    



r  c                   @   sX   e Zd Z	 dd Zdd ZeZdd Zdd Zdd
dZ	dd Z
edd Zdd Zd	S )
FileFinderc                    sr   	 g }|D ]\ }|  fdd|D  q|| _|pd| _t| js,tt | j| _d| _t | _	t | _
d S )Nc                 3   s    | ]}| fV  qd S r   r   rp  r   r   r
   rJ     s    z&FileFinder.__init__.<locals>.<genexpr>ro   r   )r   _loadersrD   rZ   rF   r   rW   _path_mtimeset_path_cache_relaxed_path_cache)r   rD   loader_detailsloadersr   r   r  r
   r    s   

zFileFinder.__init__c                 C   s   	 d| _ d S )Nr   )r  rS  r   r   r
   r    rV   zFileFinder.invalidate_cachesc                 C   s8   	 t dt | |}|d u rd g fS |j|jpg fS )NzeFileFinder.find_loader() is deprecated and slated for removal in Python 3.12; use find_spec() instead)rq   rr   rs   r  r   r   )r   r   r   r   r   r
   r     s   
zFileFinder.find_loaderc                 C   s   |||}t ||||dS )Nr   )r  )r   r   r   rD   smslr  r   r   r   r
   r    s   
zFileFinder._get_specNc              	   C   s|  	 d}| dd }zt| jpt j}W n ty!   d}Y nw || jkr.|   || _t	 r9| j
}| }n| j}|}||v rmt| j|}| jD ]\}	}
d|	 }t||}t|rh| |
|||g|  S qKt|}| jD ]7\}	}
z
t| j||	 }W n ty   Y  d S w tjd|dd ||	 |v rt|r| |
||d |  S qp|rtd| t|d }|g|_|S d S )	NFro   rl   r   r  z	trying {})	verbosityzpossible namespace for {})rv   rO   rD   r   rW   rc  rP   r  _fill_cacher   r  r   r  rF   r  rU   r  rX   r}   r   r   r   r   )r   r   r  is_namespacetail_moduler   cachecache_module	base_pathrq  r   init_filename	full_pathr   r   r   r
   r     sX   



zFileFinder.find_specc           	   
   C   s   	 | j }zt|pt }W n tttfy   g }Y nw tj	ds*t
|| _n%t
 }|D ]}|d\}}}|rDd|| }n|}|| q/|| _tj	tr_dd |D | _d S d S )Nr   ro   r\   c                 S   s   h | ]}|  qS r   )r   )r   fnr   r   r
   r   P  s    z)FileFinder._fill_cache.<locals>.<setcomp>)rD   r   listdirrW   r  PermissionErrorNotADirectoryErrorr   r   r   r  r  r   r^   r   addr   r  )	r   rD   contentslower_suffix_contentsr  r   r  rq  new_namer   r   r
   r  3  s(   zFileFinder._fill_cachec                    s   	  fdd}|S )Nc                    s&   	 t | std| d | gR  S )Nzonly directories are supportedrI   )rX   r   rI   r  r  r   r
   path_hook_for_FileFinder\  s   z6FileFinder.path_hook.<locals>.path_hook_for_FileFinderr   )r  r  r  r   r  r
   	path_hookR  s   zFileFinder.path_hookc                 C   r  )NzFileFinder({!r}))r^   rD   rS  r   r   r
   r  d  r  zFileFinder.__repr__r   )r   r   r   r  r  r   r  r   r  r  r  r  r  r  r   r   r   r
   r    s    
3
r  c                 C   s   |  d}|  d}|s!|r|j}n||krt||}nt||}|s*t|||d}z|| d< || d< || d< || d< W d S  tyG   Y d S w )N
__loader____spec__r  __file__
__cached__)getr   rk  rb  r  	Exception)nsr   pathname	cpathnamer   r   r   r   r
   _fix_up_modulej  s$   


r  c                  C   s(   	 t t f} ttf}ttf}| ||gS r   )r[  r   extension_suffixesrb  r   rk  r   )
extensionssourcebytecoder   r   r
   r     s
   
r   c                 C   s   | a d S r   )r   )_bootstrap_moduler   r   r
   _set_bootstrap_module  s   r  c                 C   s4   	 t |  t }tjtj| g tjt	 d S r   )
r  r   r   r  r   r  r  	meta_pathr@   r  )r  supported_loadersr   r   r
   _install  s
   r  )r[   r   )NNN)r   r   )T)Sr   r   rd   r   rq   r   r   r  ntr   r  posixr4   r>   r   r<   rA   _pathseps_with_colonr   %_CASE_INSENSITIVE_PLATFORMS_BYTES_KEYr   r   r   r&   r-   r/   rF   rM   rO   rT   rU   rX   rZ   rk   type__code__r   r$   r   r#   r*   rA  r   r~   r   r@   r  r  r   DEBUG_BYTECODE_SUFFIXESOPTIMIZED_BYTECODE_SUFFIXESr   r   r   r   r   r   r   r   r   r   r   r   r   r   objectr   r  r  r  r.  rH  rb  rk  r[  ru  r  r  r  r  r   r  r  r   r   r   r
   <module>   s    





	


 
G(!



IC 2-5E1   
