
    F\h                     t    S SK Jr  S SKJr  SSKJr   " S S5      r " S S5      rSS	 jr " S
 S5      r	S r
g)    )suppress)TextIOWrapper   )abcc                   ,    \ rS rSrSrS 4S jrS rSrg)SpecLoaderAdapter   z6
Adapt a package spec to adapt the underlying loader.
c                     U R                   $ N)loaderspecs    4/usr/lib/python3.13/importlib/resources/_adapters.py<lambda>SpecLoaderAdapter.<lambda>   s    $++    c                 *    Xl         U" U5      U l        g r   )r   r   )selfr   adapters      r   __init__SpecLoaderAdapter.__init__   s    	dmr   c                 .    [        U R                  U5      $ r   )getattrr   r   names     r   __getattr__SpecLoaderAdapter.__getattr__   s    tyy$''r   )r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r   r      s     &> $(r   r   c                   $    \ rS rSrSrS rS rSrg)TraversableResourcesLoader   z1
Adapt a loader to provide TraversableResources.
c                     Xl         g r   r   r   r   s     r   r   #TraversableResourcesLoader.__init__       	r   c                 H    [        U R                  5      R                  5       $ r   )CompatibilityFilesr   _nativer   s     r   get_resource_reader.TraversableResourcesLoader.get_resource_reader   s    !$)),4466r   r   N)r   r   r    r!   r"   r   r/   r#   r$   r   r   r&   r&      s    7r   r&   c                 Z    US:X  a  [        U /UQ70 UD6$ US:X  a  U $ [        SU S35      e)NrrbzInvalid mode value 'z"', only 'r' and 'rb' are supported)r   
ValueError)filemodeargskwargss       r   _io_wrapperr9       s@    s{T3D3F33	
+D61ST
UUr   c                       \ rS rSrSr " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r	S	 r
\S
 5       rS rS rS rSrg)r-   (   z^
Adapter for an existing or non-existent resource reader
to provide a compatibility .files().
c                   N    \ rS rSrSrS rS rS r\rS r	\
S 5       rSS jrS	rg
)CompatibilityFiles.SpecPath.   zS
Path tied to a module spec.
Can be read and exposes the resource reader children.
c                     Xl         X l        g r   )_spec_reader)r   r   readers      r   r   $CompatibilityFiles.SpecPath.__init__4   s    J!Lr   c                    ^  T R                   (       d  [        S5      $ [        U 4S jT R                   R                  5        5       5      $ )Nr$   c              3   d   >#    U  H%  n[         R                  TR                  U5      v   M'     g 7fr   )r-   	ChildPathrA   ).0pathr   s     r   	<genexpr>6CompatibilityFiles.SpecPath.iterdir.<locals>.<genexpr>;   s,      3D #,,T\\4@@3s   -0)rA   itercontentsr   s   `r   iterdir#CompatibilityFiles.SpecPath.iterdir8   s:    <<Bx  LL113  r   c                     gNFr$   rM   s    r   is_file#CompatibilityFiles.SpecPath.is_file@       r   c                     U R                   (       d  [        R                  U5      $ [        R                  U R                   U5      $ r   )rA   r-   
OrphanPathrF   r   others     r   joinpath$CompatibilityFiles.SpecPath.joinpathE   s1    <<)44U;;%//eDDr   c                 .    U R                   R                  $ r   )r@   r   rM   s    r   r    CompatibilityFiles.SpecPath.nameJ   s    ::??"r   c                 T    [        U R                  R                  S 5      U/UQ70 UD6$ r   )r9   rA   open_resourcer   r6   r7   r8   s       r   open CompatibilityFiles.SpecPath.openN   s)    t||99$?WWPVWWr   )rA   r@   Nr2   r   r   r    r!   r"   r   rN   rR   is_dirrY   propertyr   r`   r#   r$   r   r   SpecPathr=   .   s=    	
	"		 	E
 
	# 
	#	Xr   rf   c                   P    \ rS rSrSrS rS rS rS rS r	\
S 5       rSS	 jrS
rg)CompatibilityFiles.ChildPathQ   z_
Path tied to a resource reader child.
Can be read but doesn't expose any meaningful children.
c                     Xl         X l        g r   )rA   _name)r   rB   r   s      r   r   %CompatibilityFiles.ChildPath.__init__W   s    !LJr   c                     [        S5      $ Nr$   rK   rM   s    r   rN   $CompatibilityFiles.ChildPath.iterdir[       8Or   c                 L    U R                   R                  U R                  5      $ r   )rA   is_resourcer   rM   s    r   rR   $CompatibilityFiles.ChildPath.is_file^   s    <<++DII66r   c                 ,    U R                  5       (       + $ r   )rR   rM   s    r   rd   #CompatibilityFiles.ChildPath.is_dira   s    ||~%%r   c                 B    [         R                  U R                  U5      $ r   )r-   rV   r   rW   s     r   rY   %CompatibilityFiles.ChildPath.joinpathd   s    %00EBBr   c                     U R                   $ r   )rk   rM   s    r   r   !CompatibilityFiles.ChildPath.nameg   s    ::r   c                 h    [        U R                  R                  U R                  5      U/UQ70 UD6$ r   )r9   rA   r^   r   r_   s       r   r`   !CompatibilityFiles.ChildPath.openk   s7    **4995t>BFL r   )rk   rA   Nrb   rc   r$   r   r   rF   rh   Q   s:    	
			7	&	C 
	 
		r   rF   c                   N    \ rS rSrSrS rS rS r\rS r	\
S 5       rSS jrS	rg
)CompatibilityFiles.OrphanPathp   zv
Orphan path, not tied to a module spec or resource reader.
Can't be read and doesn't expose any meaningful children.
c                 D    [        U5      S:  a  [        S5      eXl        g )Nr   z/Need at least one path part to construct a path)lenr4   _path)r   
path_partss     r   r   &CompatibilityFiles.OrphanPath.__init__v   s    :" !RSS#Jr   c                     [        S5      $ rn   ro   rM   s    r   rN   %CompatibilityFiles.OrphanPath.iterdir{   rq   r   c                     grQ   r$   rM   s    r   rR   %CompatibilityFiles.OrphanPath.is_file~   rT   r   c                 F    [         R                  " / U R                  QUP76 $ r   )r-   rV   r   rW   s     r   rY   &CompatibilityFiles.OrphanPath.joinpath   s    %00D$**DeDDr   c                      U R                   S   $ )Nr   rM   s    r   r   "CompatibilityFiles.OrphanPath.name   s    ::b>!r   c                     [        S5      e)NzCan't open orphan path)FileNotFoundErrorr_   s       r   r`   "CompatibilityFiles.OrphanPath.open   s    #$<==r   r   Nrb   rc   r$   r   r   rV   r~   p   s<    	
	$
		 	E 
	" 
	"	>r   rV   c                     Xl         g r   r   r)   s     r   r   CompatibilityFiles.__init__   r+   r   c                     [        [        5         U R                  R                  R	                  U R                  R
                  5      sS S S 5        $ ! , (       d  f       g = fr   )r   AttributeErrorr   r   r/   r   rM   s    r   rA   CompatibilityFiles._reader   s6    n%99##77		G &%%s   9A
A!c                 D    U R                   n[        US5      (       a  U$ U $ )z2
Return the native reader if it supports files().
files)rA   hasattr)r   rB   s     r   r.   CompatibilityFiles._native   s$      11v;t;r   c                 .    [        U R                  U5      $ r   )r   rA   )r   attrs     r   r   CompatibilityFiles.__getattr__   s    t||T**r   c                 V    [         R                  U R                  U R                  5      $ r   )r-   rf   r   rA   rM   s    r   r   CompatibilityFiles.files   s    !**499dllCCr   r   N)r   r   r    r!   r"   r   Traversablerf   rF   rV   r   re   rA   r.   r   r   r#   r$   r   r   r-   r-   (   se    
!X3?? !XFCOO >>S__ >: H H<+Dr   r-   c                 6    [        U R                  [        5      $ )zT
Construct a package spec with traversable compatibility
on the spec/loader/reader.
)r   __spec__r&   )packages    r   	wrap_specr      s    
 W--/IJJr   Nrb   )
contextlibr   ior    r   r   r&   r9   r-   r   r$   r   r   <module>r      s=      
( 
(	7 	7VxD xDvKr   