U
    ½mœd  ã                   @   s®   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mZm	Z	m
Z
mZ ddlmZmZmZ dddgZG dd„ de jd	�ZG d
d„ deƒZeG dd„ deƒƒZG dd„ deƒZdS )é    N)ÚAnyÚBinaryIOÚIterableÚIteratorÚNoReturnÚTextÚOptionalé   )Úruntime_checkableÚProtocolÚStrPathÚResourceReaderÚTraversableÚTraversableResourcesc                   @   sj   e Zd ZdZejeedœdd„ƒZejeedœdd„ƒZ	ejee
dœdd	„ƒZejee d
œdd„ƒZdS )r   zDAbstract base class for loaders to provide resource reading support.©ÚresourceÚreturnc                 C   s   t ‚dS )zÑReturn an opened, file-like object for binary reading.

        The 'resource' argument is expected to represent only a file name.
        If the resource cannot be found, FileNotFoundError is raised.
        N©ÚFileNotFoundError©Úselfr   © r   úP/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/importlib_resources/abc.pyÚopen_resource   s    
zResourceReader.open_resourcec                 C   s   t ‚dS )zçReturn the file system path to the specified resource.

        The 'resource' argument is expected to represent only a file name.
        If the resource does not exist on the file system, raise
        FileNotFoundError.
        Nr   r   r   r   r   Úresource_path   s    zResourceReader.resource_path©Úpathr   c                 C   s   t ‚dS )zjReturn True if the named 'path' is a resource.

        Files are resources, directories are not.
        Nr   ©r   r   r   r   r   Úis_resource)   s    zResourceReader.is_resource©r   c                 C   s   t ‚dS )z+Return an iterable of entries in `package`.Nr   ©r   r   r   r   Úcontents1   s    zResourceReader.contentsN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚabcÚabstractmethodr   r   r   r   Úboolr   r   Ústrr!   r   r   r   r   r      s   )Ú	metaclassc                   @   s   e Zd ZdS )ÚTraversalErrorN)r"   r#   r$   r   r   r   r   r+   7   s   r+   c                   @   s¼   e Zd ZdZejed  dœdd„ƒZedœdd„Z	de
e edœd	d
„Zejedœdd„ƒZejedœdd„ƒZed dœdd„Zed dœdd„Zejddd„ƒZeejedœdd„ƒƒZdS )r   zÔ
    An object with a subset of pathlib.Path methods suitable for
    traversing directories and opening files.

    Any exceptions that occur when accessing the backing resource
    may propagate unaltered.
    r   c                 C   s   dS )z3
        Yield Traversable objects in self
        Nr   r    r   r   r   ÚiterdirE   s    zTraversable.iterdirc              
   C   s*   |   d¡�}| ¡ W  5 Q R £ S Q R X dS )z0
        Read contents of self as bytes
        ÚrbN©ÚopenÚread)r   Ústrmr   r   r   Ú
read_bytesK   s    zTraversable.read_bytesN)Úencodingr   c              
   C   s,   | j |d��}| ¡ W  5 Q R £ S Q R X dS )z/
        Read contents of self as text
        )r3   Nr.   )r   r3   r1   r   r   r   Ú	read_textR   s    zTraversable.read_textc                 C   s   dS )z4
        Return True if self is a directory
        Nr   r    r   r   r   Úis_dirY   s    zTraversable.is_dirc                 C   s   dS )z/
        Return True if self is a file
        Nr   r    r   r   r   Úis_file_   s    zTraversable.is_file)Údescendantsr   c                    s€   |s| S t j dd„ ttj|ƒD ƒ¡}t|ƒ‰ ‡ fdd„|  ¡ D ƒ}zt|ƒ}W n$ tk
rt   t	dˆ t
|ƒƒ‚Y nX |j|Ž S )zë
        Return Traversable resolved with any descendants applied.

        Each descendant should be a path segment relative to self
        and each may contain multiple levels separated by
        ``posixpath.sep`` (``/``).
        c                 s   s   | ]}|j V  qd S ©N)Úparts)Ú.0r   r   r   r   Ú	<genexpr>o   s    z'Traversable.joinpath.<locals>.<genexpr>c                 3   s   | ]}|j ˆ kr|V  qd S r8   ©Úname)r:   Ztraversable©Útargetr   r   r;   s   s    
 z"Target not found during traversal.)Ú	itertoolsÚchainÚfrom_iterableÚmapÚpathlibÚPurePosixPathÚnextr,   ÚStopIterationr+   ÚlistÚjoinpath)r   r7   ÚnamesÚmatchesÚmatchr   r>   r   rI   e   s$    
ÿ
ÿ  ÿ
zTraversable.joinpath)Úchildr   c                 C   s
   |   |¡S )z2
        Return Traversable child in self
        )rI   )r   rM   r   r   r   Ú__truediv__~   s    zTraversable.__truediv__Úrc                 O   s   dS )zý
        mode may be 'r' or 'rb' to open as text or binary. Return a handle
        suitable for reading (same as pathlib.Path.open).

        When opening as text, accepts encoding parameters such as those
        accepted by io.TextIOWrapper.
        Nr   )r   ÚmodeÚargsÚkwargsr   r   r   r/   „   s    zTraversable.openc                 C   s   dS )zM
        The base name of this object without any parent references.
        Nr   r    r   r   r   r=   Ž   s    zTraversable.name)N)rO   )r"   r#   r$   r%   r&   r'   r   r,   Úbytesr2   r   r)   r4   r(   r5   r6   r   rI   rN   r/   Úpropertyr=   r   r   r   r   r   ;   s    	c                   @   sh   e Zd ZdZejddœdd„ƒZeej	dœdd„Z
eedœd	d
„Zeedœdd„Zee dœdd„ZdS )r   zI
    The required interface for providing traversable
    resources.
    r   r   c                 C   s   dS )z3Return a Traversable object for the loaded package.Nr   r    r   r   r   Úfilesœ   s    zTraversableResources.filesr   c                 C   s   |   ¡  |¡ d¡S )Nr-   )rU   rI   r/   r   r   r   r   r       s    z"TraversableResources.open_resourcec                 C   s   t |ƒ‚d S r8   r   r   r   r   r   r   £   s    z"TraversableResources.resource_pathr   c                 C   s   |   ¡  |¡ ¡ S r8   )rU   rI   r6   r   r   r   r   r   ¦   s    z TraversableResources.is_resourcec                 C   s   dd„ |   ¡  ¡ D ƒS )Nc                 s   s   | ]}|j V  qd S r8   r<   )r:   Úitemr   r   r   r;   ª   s     z0TraversableResources.contents.<locals>.<genexpr>)rU   r,   r    r   r   r   r!   ©   s    zTraversableResources.contentsN)r"   r#   r$   r%   r&   r'   rU   r   ÚioÚBufferedReaderr   r   r   r   r(   r   r   r)   r!   r   r   r   r   r   –   s   )r&   rW   r@   rD   Útypingr   r   r   r   r   r   r   Z_compatr
   r   r   Ú__all__ÚABCMetar   Ú	Exceptionr+   r   r   r   r   r   r   Ú<module>   s   $
*Z