
    ;e                         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 Z G d dej	                  Z
 G d d	ej	                  Z G d
 dej                  Z G d dej	                  ZdS )    N   )abc)unique_everseenc                 Z    t          t          j                            |                     S N)itercollectionsOrderedDictfromkeys)itemss    2/usr/lib/python3.11/importlib/resources/readers.pyremove_duplicatesr      s!    '0077888    c                        e Zd Zd Zd Zd ZdS )
FileReaderc                 L    t          j        |j                  j        | _        d S r   )pathlibPathpathparent)selfloaders     r   __init__zFileReader.__init__   s    L--4			r   c                 R    	 t          | j                            |                    S r   strr   joinpathr   resources     r   resource_pathzFileReader.resource_path   '    	
 49%%h//000r   c                     | j         S r   r   r   s    r   fileszFileReader.files   
    yr   N__name__
__module____qualname__r   r    r%    r   r   r   r      sA        5 5 51 1 1    r   r   c                   0     e Zd Zd Z fdZd Zd Z xZS )	ZipReaderc                     |                     d          \  }}}|j                            dd          |z   dz   | _        |j        | _        d S )N.\/)
rpartitionprefixreplacearchive)r   r   module_names        r   r   zZipReader.__init__    sK    &&s++
1dm++D#66=C~r   c                     	 t                                          |          S # t          $ r}t          |j        d                   d }~ww xY wNr   )superopen_resourceKeyErrorFileNotFoundErrorargs)r   r   exc	__class__s      r   r<   zZipReader.open_resource%   sS    	177((222 	1 	1 	1#CHQK000	1s    $ 
AAAc                     |                                                      |          }|                                o|                                S r   )r%   r   is_fileexists)r   r   targets      r   is_resourcezZipReader.is_resource+   s<     &&t,,~~3FMMOO3r   c                 @    t          j        | j        | j                  S r   )zipfiler   r5   r3   r$   s    r   r%   zZipReader.files1   s    |DL$+666r   )r(   r)   r*   r   r<   rF   r%   __classcell__)rA   s   @r   r-   r-      se        & & &
1 1 1 1 14 4 47 7 7 7 7 7 7r   r-   c                   `    e Zd Z	 d Zd Zd Zd Zd Zd Zd Z	e	Z
d Zed	             Zd
 ZdS )MultiplexedPathc                    t          t          t          j        t	          |                              | _        | j        sd}t          |          t          d | j        D                       st          d          d S )Nz.MultiplexedPath must contain at least one pathc              3   >   K   | ]}|                                 V  d S r   )is_dir.0r   s     r   	<genexpr>z+MultiplexedPath.__init__.<locals>.<genexpr>B   s*      99T4;;==999999r   z)MultiplexedPath only supports directories)	listmapr   r   r   _pathsr>   allNotADirectoryError)r   pathsmessages      r   r   zMultiplexedPath.__init__=   s    3w|->u-E-EFFGG{ 	-FG#G,,,99T[99999 	R$%PQQQ	R 	Rr   c                 j    d | j         D             }t          |t          j        d                    S )Nc              3   H   K   | ]}|                                 D ]}|V  d S r   )iterdir)rP   r   files      r   rQ   z*MultiplexedPath.iterdir.<locals>.<genexpr>F   s7      II$$,,..II$IIIIIIIr   r8   )key)rT   r   operator
attrgetter)r   r%   s     r   r[   zMultiplexedPath.iterdirE   s5    II$+IIIu(*=f*E*EFFFFr   c                 &    t          |  d          Nz is not a filer>   r$   s    r   
read_byteszMultiplexedPath.read_bytesI       4 7 7 7888r   c                 &    t          |  d          ra   rb   r   r?   kwargss      r   	read_textzMultiplexedPath.read_textL   rd   r   c                     dS )NTr+   r$   s    r   rN   zMultiplexedPath.is_dirO   s    tr   c                     dS )NFr+   r$   s    r   rC   zMultiplexedPath.is_fileR   s    ur   c                 n    |                                  D ]}|j        |k    r|c S | j        d         |z  S r:   )r[   r8   rT   )r   childr\   s      r   r   zMultiplexedPath.joinpathU   sG    LLNN 	 	DyE!! " {1~%%r   c                 &    t          |  d          ra   rb   rf   s      r   openzMultiplexedPath.open_   rd   r   c                 &    | j         d         j        S r:   )rT   r8   r$   s    r   r8   zMultiplexedPath.nameb   s    {1~""r   c                 V    d                     d | j        D                       }d| dS )Nz, c              3   "   K   | ]
}d | d V  dS )'Nr+   rO   s     r   rQ   z+MultiplexedPath.__repr__.<locals>.<genexpr>g   s*      >>$+d+++>>>>>>r   zMultiplexedPath())joinrT   )r   rW   s     r   __repr__zMultiplexedPath.__repr__f   s5    		>>$+>>>>>*%****r   N)r(   r)   r*   r   r[   rc   rh   rN   rC   r   __truediv__rn   propertyr8   ru   r+   r   r   rK   rK   5   s        R R RG G G9 9 99 9 9    & & & K9 9 9 # # X#+ + + + +r   rK   c                        e Zd Zd Zd Zd ZdS )NamespaceReaderc                 |    dt          |          vrt          d          t          t          |           | _        d S )NNamespacePathzInvalid path)r   
ValueErrorrK   rR   r   )r   namespace_paths     r   r   zNamespaceReader.__init__l   s;    #n"5"555^,,,#T.%9%9:			r   c                 R    	 t          | j                            |                    S r   r   r   s     r   r    zNamespaceReader.resource_pathq   r!   r   c                     | j         S r   r#   r$   s    r   r%   zNamespaceReader.filesy   r&   r   Nr'   r+   r   r   ry   ry   k   sA        ; ; ;
1 1 1    r   ry   )r	   r^   r   rH    r   
_itertoolsr   r   TraversableResourcesr   r-   TraversablerK   ry   r+   r   r   <module>r      s                ' ' ' ' ' '9 9 9    )    7 7 7 7 7( 7 7 7,3+ 3+ 3+ 3+ 3+co 3+ 3+ 3+l    c.     r   