
    F\h                     <   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
JrJrJr  SSKJrJr  \\R"                  \4   r\rS r\SS\\   S\4S jj5       rS	\R"                  S\\   4S
 jr\R0                  S\\   S\R"                  4S j5       r\R4                  S\S\R"                  4S j5       r\R4                  SSS\R"                  4S j5       rS rS	\R"                  4S jr\R<                   S\ R>                  S.S jj5       r S r!S\S\"4S jr#\R0                  S 5       r$\$R5                  \RJ                  5      \R<                  S 5       5       r\R<                  S\RL                  4S j5       r'\R<                  S 5       r(S r)g)    N)UnionOptionalcast   )ResourceReaderTraversablec                 f   ^ ^ [        5       m[        R                  " T 5      TT4U U4S jj5       nU$ )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

Remove this compatibility in Python 3.14.
c                    > UTLa/  U TLa  T" X5      $ [         R                  " S[        SS9  T" U5      $ U TL a  T" 5       $ T" U 5      $ )Nz/First parameter to files is renamed to 'anchor'   )
stacklevel)warningswarnDeprecationWarning)anchorpackagefunc	undefineds     2/usr/lib/python3.13/importlib/resources/_common.pywrapper"package_to_anchor.<locals>.wrapper!   sX    )#Y&F,,MMA"
 = y 6MF|    )object	functoolswraps)r   r   r   s   ` @r   package_to_anchorr      s3     I__T )   Nr   r   returnc                 *    [        [        U 5      5      $ )z+
Get a Traversable resource for an anchor.
)from_packageresolve)r   s    r   filesr    3   s    
 ((r   r   c                 t    U R                   n[        UR                  SS5      nUc  gU" UR                  5      $ )z7
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    [        [        R                  U 5      $ N)r   types
ModuleTyper)   s    r   r   r   K   s      $''r   c                 .    [         R                  " U 5      $ r+   )	importlibimport_moduler.   s    r   _r2   P   s    ""4((r   c                 B    [        [        5       R                  S   5      $ )N__name__)r   _infer_caller	f_globalsr.   s    r   r2   r2   U   s    =?,,Z899r   c                      S n S n[         R                  " U [        R                  " 5       5      n[         R                  " X5      n[	        U5      R
                  $ )zK
Walk the stack and find the frame of the first caller not in this module.
c                 (    U R                   [        :H  $ r+   )filename__file__
frame_infos    r   is_this_file#_infer_caller.<locals>.is_this_file_   s    ""h..r   c                      U R                   S:H  $ )Nr   )functionr;   s    r   
is_wrapper!_infer_caller.<locals>.is_wrapperb   s    ""i//r   )	itertoolsfilterfalseinspectstacknextframe)r=   rA   not_this_filecallerss       r   r5   r5   Z   sF    
/0 )),HM##J>G=r   c                     SSK Jn  U" U 5      nUR                  R                  UR                  5      nUR                  5       $ )z5
Return a Traversable object for the given package.

r   )	wrap_spec)	_adaptersrL   r%   r"   r&   r    )r   rL   r'   r(   s       r   r   r   k   s5     %WD[[,,TYY7F<<>r   )
_os_removec             #   t  #    [         R                  " US9u  p4  [        R                  " X0" 5       5        [        R                  " U5        A [
        R                  " U5      v    U" U5        g ! [        R                  " U5        f = f! [         a     g f = f!  U" U5        f ! [         a     f f = f= f7fN)suffix)tempfilemkstemposwriteclosepathlibPathFileNotFoundError)r(   rQ   rN   fdraw_paths        r   	_tempfiler\   x   s      ##62LB	HHR"HHRLll8$$	x  HHRL ! 			x   		so   B8A/ /B &B
 .B8/BB 

BB8BB8B5B%$B5%
B2/B51B22B55B8c                 >    [        U R                  U R                  S9$ rP   )r\   
read_bytesr&   paths    r   
_temp_filera      s    T__TYY77r   r`   c                     [         R                  " [        5         U R                  5       sSSS5        $ ! , (       d  f       g= f)z
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suppressrY   is_dirr_   s    r   _is_present_dirrf      s+     
		.	/{{} 
0	/	/s	   5
Ac                 N    [        U 5      (       a  [        U 5      $ [        U 5      $ )zi
Given a Traversable object, return that object as a
path on the local file system in a context manager.
)rf   	_temp_dirra   r_   s    r   as_fileri      s"     .d339T?ID9IIr   c              #      #    U v   g7f)z/
Degenerate behavior for pathlib.Path objects.
N r_   s    r   r2   r2      s      Js   dirc              #   t   #    U  n[         R                  " U5      v   SSS5        g! , (       d  f       g= f7f)z<
Wrap tempfile.TemporyDirectory to return a pathlib object.
N)rW   rX   )rl   results     r   
_temp_pathro      s$     
 
ll6"" 
s   8'	8
58c              #      #    U R                  5       (       d   e[        [        R                  " 5       5       n[	        X5      v   SSS5        g! , (       d  f       g= f7f)zh
Given a traversable dir, recursively replicate the whole tree
to the file system in a context manager.
N)re   ro   rR   TemporaryDirectory_write_contents)r`   temp_dirs     r   rh   rh      s@      ;;===	H//1	2hh-- 
3	2	2s   6A A	A 
AA c                    U R                  UR                  5      nUR                  5       (       a4  UR                  5         UR	                  5        H  n[        X#5        M     U$ UR                  UR                  5       5        U$ r+   )joinpathr&   re   mkdiriterdirrr   write_bytesr^   )targetsourcechilditems       r   rr   rr      sf    OOFKK(E}}NN$DE( % L 	&++-.Lr   r+   ) )*rT   rW   rR   r   rc   r,   r0   rE   r   rC   typingr   r   r   abcr   r   r-   strPackageAnchorr   r    r"   singledispatchr   registerr2   r5   r   contextmanagerremover\   ra   boolrf   ri   rX   rq   ro   rh   rr   rk   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   