o
    ùT·j	  ã                   @  s’   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
 dgZG dd„ dejjƒZG dd	„ d	ejjƒZddd„Zddd„ZdS )é    )ÚannotationsN)ÚSequence)Ú
ModuleTypeÚalias_httpxc                   @  s4   e Zd ZU ded< ddd„Zddd„Zddd„ZdS )Ú_AliasLoaderú%importlib.machinery.ModuleSpec | NoneÚ_original_specÚ	real_nameÚstrÚreturnÚNonec                 C  s
   || _ d S ©N)Ú
_real_name)Úselfr	   © r   úP/home/dinkstrade/pdmp-scanner/venv/lib/python3.10/site-packages/httpx2/_alias.pyÚ__init__   s   
z_AliasLoader.__init__Úspecúimportlib.machinery.ModuleSpecr   c                 C  s   t  | j¡}|j| _|S r   )Ú	importlibÚimport_moduler   Ú__spec__r   )r   r   Úmoduler   r   r   Úcreate_module   s   z_AliasLoader.create_moduler   c                 C  s   | j |_d S r   )r   r   )r   r   r   r   r   Úexec_module   s   z_AliasLoader.exec_moduleN)r	   r
   r   r   )r   r   r   r   )r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__annotations__r   r   r   r   r   r   r   r      s
   
 

r   c                   @  s&   e Zd Zddd„Z		dddd„ZdS )Ú_AliasFinderÚaliasr
   Úrealr   r   c                 C  s   || _ || _d S r   )Ú_aliasÚ_real)r   r    r!   r   r   r   r      s   
z_AliasFinder.__init__NÚfullnameÚpathúSequence[str] | NoneÚtargetúModuleType | Noner   c                 C  s`   || j kr| | j d ¡sd S | j| | j ¡ }|tjvr'tj |¡d u r'd S tj	 
|t|ƒ¡S )NÚ.)r"   Ú
startswithr#   ÚremoveprefixÚsysÚmodulesr   ÚutilÚ	find_specÚ	machineryÚ
ModuleSpecr   )r   r$   r%   r'   r	   r   r   r   r/   "   s   z_AliasFinder.find_spec)r    r
   r!   r
   r   r   )NN)r$   r
   r%   r&   r'   r(   r   r   )r   r   r   r   r/   r   r   r   r   r      s
    
ür   r    r
   r   r   r   r   c                   sl   t j ˆ ¡}|d ur||urtˆ › dˆ › d�ƒ‚t‡ fdd„t jD ƒƒs/t j dtˆ |jƒ¡ |t jˆ < d S )Nz? was already imported; call `alias_httpx()` before any `import z`.c                 3  s$   � | ]}t |tƒo|jˆ kV  qd S r   )Ú
isinstancer   r"   )Ú.0Úfinder©r    r   r   Ú	<genexpr>5   s   €" z_alias.<locals>.<genexpr>r   )	r,   r-   ÚgetÚRuntimeErrorÚanyÚ	meta_pathÚinsertr   r   )r    r   Úexistingr   r5   r   r"   0   s   r"   c                  C  s(   ddl } ddl}td|ƒ td| ƒ dS )az  
    Make `import httpx` resolve to `httpx2`, and `import httpcore` to `httpcore2`, process-wide.

    Intended for applications migrating from `httpx`, so that dependencies still
    importing `httpx` or `httpcore` share the `httpx2` classes. Libraries should never call this.

    Must be called before anything imports `httpx` or `httpcore`. Calling it again is a no-op.
    r   NÚhttpxÚhttpcore)Ú	httpcore2Úhttpx2r"   )r?   r@   r   r   r   r   :   s   	
)r    r
   r   r   r   r   )r   r   )Ú
__future__r   r   Úimportlib.abcÚimportlib.machineryÚimportlib.utilr,   Úcollections.abcr   Útypesr   Ú__all__ÚabcÚLoaderr   ÚMetaPathFinderr   r"   r   r   r   r   r   Ú<module>   s    

