
     [1f                        d dl mZ d dlZd dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 d dlm
Z
 dd	lmZ dd
lmZ ddlmZ d dlmZ  G d de      Zh dZdddZy)    )annotationsN)
ModuleType)Any)Callable)cast)Iterable   )_py_abspath)	importobj)_synchronized)AliasModulec                       e Zd ZU dZddZddZ eee      Zded<   	 	 d	 	 	 	 	 	 	 	 	 d fdZd Z	e
d fd	       Zd	 Zd fd
Zedd       Z xZS )	ApiModulez(the magical lazy-loading module standingc                    	 | j                   S # t        $ r2 d| j                  v r!t        t        | j                  d            cY S Y y w xY w)N__doc__)_ApiModule__docAttributeError__map__r   str_ApiModule__makeattr)selfs    ?lib/python3.12/site-packages/menuinst/_vendor/apipkg/_module.py__docgetzApiModule.__docget   sE    	:: 	DLL(C!;<<		s    6A	A	c                    || _         y N)r   )r   values     r   __docsetzApiModule.__docset   s	    
    zdict[str, tuple[str, str]]r   c                   t         |   |       || _        |D cg c]
  }|dk7  s	| c}| _        i | _        |xs || _        |r%|j                         D ]  \  }}t        | ||        |j                         D ]  \  }}t        |t              r?| j                   d| }t        |||      }|t        j                  |<   t        | ||       U|j                  d      }	|	j                  d      }
|	xr |	d   xs d}|
d   dk(  r||
z   }
|sC| j                   d| }t        ||
      }|t        j                  |<   d|vst        | ||       |
|f| j                  |<    y c c}w )N__onfirstaccess__.:r    )super__init____name____all__r   __implprefix__itemssetattr
isinstancedictr   sysmodulessplitpopr   )r   name
importspec
implprefixattrxvalsubnameapimodpartsmodpathattrname	__class__s               r   r%   zApiModule.__init__#   su    	#-Ja6I1IJ(0D!ZZ\ )	cdC() * 0 0 2 	=D**d+!]]O1TF3"7J
C'-G$dF+"((-))A, -U1X31:$(72G!%q7G(':F+1CKK($dF3*18)<DLL&)	= Ks
   
E&E&c                   d| j                   g}t        | d      r|j                  d| j                         t        | d      r|j                  d| j                         |j                  d       dj                  |      S )Nz<ApiModule __version__z	 version=__file__z from >r#   )r&   hasattrappendr>   r?   join)r   	repr_lists     r   __repr__zApiModule.__repr__H   s}    "4=="345	4'y)9)9(<=>4$vdmm%678wwy!!r   c                   d}d| j                   v r=| j                   j                  d      }t        t        g df   t	        |       } |        	 | j                   |   \  }}t	        ||      }t        | ||       | j                   j                  |d       |S # t        $ r: ||dk7  rt        | |      cY S t        |rt        | )  |      cY S t        |      w xY w)zAlazily compute value for name or raise AttributeError if unknown.Nr    )r   r0   r   r   r   r*   KeyErrorgetattr	threadingr$   __getattribute__r   )	r   r1   	isgetattrtargetfnr:   r;   resultr<   s	           r   
__makeattrzApiModule.__makeattrQ   s     $,,.\\%%&9:Fhr4x()V*<=BD	 $T 2GX( w1FD$'LLT4(M/  	'
 !d.A&AtT** $w/55 &&#	's   B C7CCc                (    | j                  |d      S )NT)rK   )r   )r   r1   s     r   __getattr__zApiModule.__getattr__t   s    tt44r   c              #  j   K   t         |          E d {    | j                  E d {    y 7 7 wr   )r$   __dir__r   )r   r<   s    r   rS   zApiModule.__dir__w   s-     7?$$$<< 	%s   3/3133c                    t         j                  d   }|j                  |       }|/t        | d       | j                  D ]  }	 | j                  |        |S # t        $ r Y $w xY w)N__dict__some)r   rU   __get__rA   r'   r   r   )r   	dictdescrnsr1   s       r   rU   zApiModule.__dict__{   sr     ''
3	&..t4>D&! OOD)
 	 & s   A	A$#A$)return
str | None)r   r   rZ   None)NN)
r1   r   r2   dict[str, Any]r3   r[   r4   zdict[str, Any] | NonerZ   r\   )F)rZ   zIterable[str])rZ   r]   )r&   
__module____qualname__r   _ApiModule__docget_ApiModule__docsetproperty__annotations__r%   rE   r   r   rQ   rS   rU   __classcell__)r<   s   @r   r   r      s    2 x*G'' "&&*#=#= ##= 	#=
 $#= 
#=J"    D5   r   r   >   r   rU   r?   __path____spec__
__loader____package__r>   c                
   | :ddd}|j                  |       t        ||||      } | t        j                  |<   | S t	        | dd      }|rt        |      }|| _        t        | d      r(| j                  D cg c]  }t        |       c}| _        d|v rt        | d      r| `	t        |       D ]  }|t        vst        | |        t        | _        t        t        |       }t        j                  |||||       |S c c}w )a  Helper for initpkg.

    Python 3.3+ uses finer grained locking for imports, and checks sys.modules before
    acquiring the lock to avoid the overhead of the fine-grained locking. This
    introduces a race condition when a module is imported by multiple threads
    concurrently - some threads will see the initial module and some the replacement
    ApiModule. We avoid this by updating the existing module in-place.

    N)r?   rf   )r3   r4   r?   re   r   )updater   r-   r.   rH   r
   r?   rA   re   r   dir_PRESERVED_MODULE_ATTRSdelattrr<   r   r%   )	modpkgname
exportdefsr4   dfpr1   r8   s	            r   _initpkgrt      s     {40	aH"G
CT*AA3
#47LLAqKNACL
"wsI'>H 	#D22T"	#
 "i%67J7QUV Bs   8D r   )rn   zModuleType | NonerZ   r   )
__future__r   r-   rI   typesr   typingr   r   r   r   
_importingr
   r   _syncronizedr   menuinst._vendor.apipkgr   r   rl   rt    r   r   <module>r|      sE    " 
       # ! ' /w
 wt	 !r   