o
    b                     @   s   d Z ddlZddlZejd dkZejd dkZer"ddlZefZne	fZddl
mZ i Zdae Zdd	 Zeed
d Zdd Zdd Zeedd ZG dd dZG dd dZG dd dZdd ZdS )zThis module implements a post import hook mechanism styled after what is
described in PEP-369. Note that it doesn't cope with modules being reloaded.

    N         )synchronizedFc                        fdd}|S )Nc                    sF     d\}}| d}t| tj| }|D ]}t||}q|| S )N:.)split
__import__sysmodulesgetattr)modulemodule_namefunctionattrscallbackattrname M/var/www/secure340b-portal/env/lib/python3.10/site-packages/wrapt/importer.pyimport_hook&   s   

z4_create_import_hook_from_string.<locals>.import_hookr   )r   r   r   r   r   _create_import_hook_from_string%   s   r   c                 C   s   t | tr	t| } tsdatjdt  t	|d }|d u r;tj
	|d }|d ur4g t|< | | d S | gt|< d S |g krJtj
| }| | d S t| |  d S NTr   )
isinstancestring_typesr   _post_import_hooks_initr   	meta_pathinsertImportHookFinder_post_import_hooksgetr   append)hookr   hooksr   r   r   r   register_post_import_hook0   s    

r&   c                    r   )Nc                    s4   t  j tj j } jD ]}t||}q|| S N)r
   r   r   r   r   r   )r   r   r   
entrypointr   r   r   h   s
   

z8_create_import_hook_from_entrypoint.<locals>.import_hookr   )r)   r   r   r(   r   #_create_import_hook_from_entrypointg   s   r*   c                 C   sL   zdd l }W n
 ty   Y d S w |j| dD ]}t|}t||j qd S )Nr   )group)pkg_resourcesImportErroriter_entry_pointsr*   r&   r   )r+   r,   r)   r   r   r   r   discover_post_import_hooksp   s   r/   c                 C   s>   t | dd }t|d }|rg t|< |D ]}||  qd S d S )N__name__)r   r!   r"   )r   r   r%   r$   r   r   r   notify_module_loaded   s   
r1   c                   @   s   e Zd Zdd ZdS )_ImportHookLoaderc                 C   s   t j| }t| |S r'   )r   r   r1   selffullnamer   r   r   r   load_module   s   
z_ImportHookLoader.load_moduleN)r0   
__module____qualname__r6   r   r   r   r   r2      s    r2   c                   @   s   e Zd Zdd Zdd ZdS )_ImportHookChainedLoaderc                 C   s
   || _ d S r'   )loader)r4   r:   r   r   r   __init__      
z!_ImportHookChainedLoader.__init__c                 C   s   | j |}t| |S r'   )r:   r6   r1   r3   r   r   r   r6      s   z$_ImportHookChainedLoader.load_moduleN)r0   r7   r8   r;   r6   r   r   r   r   r9      s    r9   c                   @   s&   e Zd Zdd ZeedddZdS )r    c                 C   s
   i | _ d S r'   )in_progress)r4   r   r   r   r;      r<   zImportHookFinder.__init__Nc              	   C   s   |t vrd S || jv rd S d| j|< z@tr@zdd l}|j|j}W n ttfy3   |	||}Y nw |r?t
|W | j|= S nt| t W | j|= S W | j|= d S | j|= w r   )r!   r=   PY3importlib.utilutil	find_specr:   r-   AttributeErrorfind_loaderr9   r
   r2   )r4   r5   path	importlibr:   r   r   r   find_module   s,   
	


zImportHookFinder.find_moduler'   )r0   r7   r8   r;   r   _post_import_hooks_lockrF   r   r   r   r   r       s    r    c                    r   )Nc                    s   t |   | S r'   )r&   )r$   r   r   r   register   s   
zwhen_imported.<locals>.registerr   )r   rH   r   r   r   when_imported   s   rI   )__doc__r   	threadingversion_infoPY2r>   rE   strr   
basestringZ
decoratorsr   r!   r   RLockrG   r   r&   r*   r/   r1   r2   r9   r    rI   r   r   r   r   <module>   s0    	
6	
@