
    
_d                         d dl 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 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y)    N   )abc)unique_everseen)ZipPathc                 R    t        t        j                  j                  |             S N)itercollectionsOrderedDictfromkeys)itemss    P/usr/lib/python3/dist-packages/setuptools/_vendor/importlib_resources/readers.pyremove_duplicatesr      s    ''00788    c                       e Zd Zd Zd Zd Zy)
FileReaderc                 `    t        j                  |j                        j                  | _        y r   )pathlibPathpathparent)selfloaders     r   __init__zFileReader.__init__   s    LL-44	r   c                 J    t        | j                  j                  |            S z{
        Return the file system path to prevent
        `resources.path()` from creating a temporary
        copy.
        strr   joinpathr   resources     r   resource_pathzFileReader.resource_path        499%%h/00r   c                     | j                   S r   r   r   s    r   fileszFileReader.files       yyr   N__name__
__module____qualname__r   r"   r'    r   r   r   r      s    51r   r   c                   0     e Zd Zd Z fdZd Zd Z xZS )	ZipReaderc                     |j                  d      \  }}}|j                  j                  dd      |z   dz   | _        |j                  | _        y )N.\/)
rpartitionprefixreplacearchive)r   r   module_names        r   r   zZipReader.__init__    sE    &&s+
1dmm++D#6=C~~r   c                 v    	 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%   s;    	17(22 	1#CHHQK00	1s    	838c                     | j                         j                  |      }|j                         xr |j                         S r   )r'   r   is_fileexists)r   r   targets      r   is_resourcezZipReader.is_resource+   s2     &&t,~~3FMMO3r   c                 B    t        | j                  | j                        S r   )r   r7   r5   r&   s    r   r'   zZipReader.files1   s    t||T[[11r   )r*   r+   r,   r   r>   rH   r'   __classcell__rC   s   @r   r/   r/      s    &
142r   r/   c                   b     e Zd ZdZd Zd Zd Zd Zd Zd Z	 fdZ
d	 Zed
        Zd Z xZS )MultiplexedPathz
    Given a series of Traversable objects, implement a merged
    version of the interface across all objects. Useful for
    namespace packages which may be multihomed at a single
    name.
    c                     t        t        t        j                  t	        |                  | _        | j
                  sd}t        |      t        d | j
                  D              st        d      y )Nz.MultiplexedPath must contain at least one pathc              3   <   K   | ]  }|j                           y wr   )is_dir.0r   s     r   	<genexpr>z+MultiplexedPath.__init__.<locals>.<genexpr>B   s     9T4;;=9s   z)MultiplexedPath only supports directories)	listmapr   r   r   _pathsr@   allNotADirectoryError)r   pathsmessages      r   r   zMultiplexedPath.__init__=   sY    3w||->u-EFG{{FG#G,,9T[[99$%PQQ :r   c                 h    d | j                   D        }t        |t        j                  d            S )Nc              3   J   K   | ]  }|j                         D ]  }|   y wr   )iterdir)rR   r   files      r   rS   z*MultiplexedPath.iterdir.<locals>.<genexpr>F   s"     I$$,,.I$IIs   !#r:   )key)rV   r   operator
attrgetter)r   r'   s     r   r]   zMultiplexedPath.iterdirE   s(    I$++Iu(*=*=f*EFFr   c                     t        |  d      Nz is not a filer@   r&   s    r   
read_byteszMultiplexedPath.read_bytesI       4& 788r   c                     t        |  d      rc   rd   r   rA   kwargss      r   	read_textzMultiplexedPath.read_textL   rf   r   c                      y)NTr-   r&   s    r   rP   zMultiplexedPath.is_dirO   s    r   c                      y)NFr-   r&   s    r   rE   zMultiplexedPath.is_fileR   s    r   c                     	 t        |   | S # t        j                  $ r  | j                  d   j                  | cY S w xY wr<   )r=   r   r   TraversalErrorrV   )r   descendantsrC   s     r   r   zMultiplexedPath.joinpathU   sJ    	97#[11!! 	9 +4;;q>**K88	9s    /A Ac                     t        |  d      rc   rd   rh   s      r   openzMultiplexedPath.open]   rf   r   c                 4    | j                   d   j                  S r<   )rV   r:   r&   s    r   r:   zMultiplexedPath.name`   s    {{1~"""r   c                 R    dj                  d | j                  D              }d| dS )Nz, c              3   (   K   | ]
  }d | d   yw)'Nr-   rQ   s     r   rS   z+MultiplexedPath.__repr__.<locals>.<genexpr>e   s     >$AdV1+>s   zMultiplexedPath())joinrV   )r   rY   s     r   __repr__zMultiplexedPath.__repr__d   s)    		>$++>>!%**r   )r*   r+   r,   __doc__r   r]   re   rj   rP   rE   r   rq   propertyr:   rx   rJ   rK   s   @r   rM   rM   5   sK    RG9999 # #+r   rM   c                       e Zd Zd Zd Zd Zy)NamespaceReaderc                 `    dt        |      vrt        d      t        t        |       | _        y )NNamespacePathzInvalid path)r   
ValueErrorrM   rT   r   )r   namespace_paths     r   r   zNamespaceReader.__init__j   s+    #n"55^,,#T.%9:	r   c                 J    t        | j                  j                  |            S r   r   r    s     r   r"   zNamespaceReader.resource_patho   r#   r   c                     | j                   S r   r%   r&   s    r   r'   zNamespaceReader.filesw   r(   r   Nr)   r-   r   r   r|   r|   i   s    ;
1r   r|   )r
   r   r`    r   
_itertoolsr   _compatr   r   TraversableResourcesr   r/   TraversablerM   r|   r-   r   r   <module>r      sc        ' 9))  2(( 2,1+coo 1+hc.. r   