
    dafS                     2   d dl Z d dlZd dlZd dlZd dl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mZmZ ddlmZmZ ddlmZ eej&                  ef   ZeZd Zeddee   defd	       Zd
ej&                  dee   fdZej4                  dee   dej&                  fd       Zej8                  dedej&                  fd       Zej8                  dddej&                  fd       Zd Zd
ej&                  fdZej@                  	 de jB                  dd       Z"d Z#dede$fdZ%ej4                  d        Z&e&j9                  ejN                        ej@                  d               Zej@                  dejP                  fd       Z)ej@                  d        Z*d Z+y)    N)UnionOptionalcast   )ResourceReaderTraversable)	wrap_specc                 `     t               t        j                         f fd	       }|S )a  
    Replace 'package' parameter as 'anchor' and warn about the change.

    Other errors should fall through.

    >>> files('a', 'b')
    Traceback (most recent call last):
    TypeError: files() takes from 0 to 1 positional arguments but 2 were given
    c                     |ur1| ur	 | |      S t        j                  dt        d        |      S | u r        S  |       S )Nz/First parameter to files is renamed to 'anchor'   )
stacklevel)warningswarnDeprecationWarning)anchorpackagefunc	undefineds     6/root/Python-3.12.4/Lib/importlib/resources/_common.pywrapperz"package_to_anchor.<locals>.wrapper!   sZ    )#Y&FG,,MMA"
 = y 6MF|    )object	functoolswraps)r   r   r   s   ` @r   package_to_anchorr      s3     I__T )   Nr   r   returnc                 *    t        t        |             S )z3
    Get a Traversable resource for an anchor.
    )from_packageresolve)r   s    r   filesr    3   s    
 ((r   r   c                 r    | j                   }t        |j                  dd      }|y ||j                        S )z?
    Return the package's loader if it's a ResourceReader.
    get_resource_readerN)__spec__getattrloadernamer   specreaders      r   r"   r"   ;   s9     DT[["7>F~$))r   candc                 6    t        t        j                  |       S N)r   types
ModuleTyper*   s    r   r   r   K   s      $''r   c                 ,    t        j                  |       S r,   )	importlibimport_moduler/   s    r   _r3   P   s    ""4((r   c                 B    t        t               j                  d         S )N__name__)r   _infer_caller	f_globalsr/   s    r   r3   r3   U   s    =?,,Z899r   c                      d } d }t        j                  | t        j                               }t        j                  ||      }t	        |      j
                  S )zS
    Walk the stack and find the frame of the first caller not in this module.
    c                 (    | j                   t        k(  S r,   )filename__file__
frame_infos    r   is_this_filez#_infer_caller.<locals>.is_this_file_   s    ""h..r   c                      | j                   dk(  S )Nr   )functionr<   s    r   
is_wrapperz!_infer_caller.<locals>.is_wrapperb   s    ""i//r   )	itertoolsfilterfalseinspectstacknextframe)r>   rA   not_this_filecallerss       r   r6   r6   Z   sH    
/0 )),HM##J>G=r   c                     t        |       }|j                  j                  |j                        }|j	                         S )z=
    Return a Traversable object for the given package.

    )r	   r%   r"   r&   r    r'   s      r   r   r   k   s2    
 WD[[,,TYY7F<<>r   )
_os_removec             #   p  K   t        j                  |      \  }}	 	 t        j                  | |               t        j                  |       ~ t        j                  |       	  ||       y # t        j                  |       w xY w# t        $ r Y y w xY w# 	  ||       w # t        $ r Y w w xY wxY wwN)suffix)tempfilemkstemposwriteclosepathlibPathFileNotFoundError)r)   rN   rK   fdraw_paths        r   	_tempfilerY   u   s      ##62LB	HHR"HHRLll8$$	x  HHRL ! 			x   		so   B6A0 -B 'B
 /B60BB 
	BB6BB6B3B$#B3$	B0-B3/B00B33B6c                 D    t        | j                  | j                        S rM   )rY   
read_bytesr&   paths    r   
_temp_filer^      s    T__TYY77r   r]   c                     t        j                  t              5  | j                         cddd       S # 1 sw Y   yxY w)a  
    Some Traversables implement ``is_dir()`` to raise an
    exception (i.e. ``FileNotFoundError``) when the
    directory doesn't exist. This function wraps that call
    to always return a boolean and only return True
    if there's a dir and it exists.
    NF)
contextlibsuppressrV   is_dirr\   s    r   _is_present_dirrc      s4     
		.	/ {{}  s   4=c                 D    t        |       rt        |       S t        |       S )zu
    Given a Traversable object, return that object as a
    path on the local file system in a context manager.
    )rc   	_temp_dirr^   r\   s    r   as_filerf      s     .d39T?ID9IIr   c              #      K   |  yw)z7
    Degenerate behavior for pathlib.Path objects.
    N r\   s    r   r3   r3      s      Js   dirc              #   h   K   | 5 }t        j                  |       ddd       y# 1 sw Y   yxY ww)zD
    Wrap tempfile.TemporyDirectory to return a pathlib object.
    N)rT   rU   )ri   results     r   
_temp_pathrl      s0     
 
 #ll6""# # #s   2&	2/2c              #      K   | j                         sJ t        t        j                               5 }t	        ||        ddd       y# 1 sw Y   yxY ww)zt
    Given a traversable dir, recursively replicate the whole tree
    to the file system in a context manager.
    N)rb   rl   rO   TemporaryDirectory_write_contents)r]   temp_dirs     r   re   re      sJ      ;;==	H//1	2 .hh--. . .s   0AA
	A
AAc                     | j                  |j                        }|j                         r3|j                          |j	                         D ]  }t        ||        |S |j                  |j                                |S r,   )joinpathr&   rb   mkdiriterdirro   write_bytesr[   )targetsourcechilditems       r   ro   ro      sk    OOFKK(E}}NN$ 	)DE4(	) L 	&++-.Lr   r,   ) ),rQ   rT   rO   r   r`   r-   r1   rD   r   rB   typingr   r   r   abcr   r   	_adaptersr	   r.   strPackageAnchorr   r    r"   singledispatchr   registerr3   r6   r   contextmanagerremoverY   r^   boolrc   rf   rU   rn   rl   re   ro   rh   r   r   <module>r      s   	          ( ( ,  
  #%
&	< )(6" )k ) )!1!1 h~6N   ((6" (u'7'7 ( ( 	)C )E$$ ) ) 	:D :U%% : :"%**    yy 48
+ 
$ 
 J J 	',,    #H// # # . .r   