U
    -c.                     @   sh   d dl Z d dlmZmZmZ ddlmZmZ G dd de jdZ	eG dd	 d	eZ
G d
d de	ZdS )    N)BinaryIOIterableText   )runtime_checkableProtocolc                   @   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 )ResourceReaderzDAbstract base class for loaders to provide resource reading support.)resourcereturnc                 C   s   t dS )zReturn 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   N/tmp/pip-unpacked-wheel-izj_87as/setuptools/_vendor/importlib_resources/abc.pyopen_resource
   s    
zResourceReader.open_resourcec                 C   s   t dS )zReturn 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   contents+   s    zResourceReader.contentsN)__name__
__module____qualname____doc__abcabstractmethodr   r   r   r   boolr   r   strr   r   r   r   r   r      s   r   )	metaclassc                   @   s   e Zd ZdZejdd Zdd ZdddZeje	d	d
dZ
eje	d	ddZejdd Zdd ZejdddZejed	ddZdS )Traversablezt
    An object with a subset of pathlib.Path methods suitable for
    traversing directories and opening files.
    c                 C   s   dS )z3
        Yield Traversable objects in self
        Nr   r   r   r   r   iterdir8   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_bytes>   s    zTraversable.read_bytesNc              
   C   s,   | j |d}| W  5 Q R  S Q R X dS )z/
        Read contents of self as text
        )encodingNr%   )r   r*   r(   r   r   r   	read_textE   s    zTraversable.read_textr   c                 C   s   dS )z4
        Return True if self is a directory
        Nr   r   r   r   r   is_dirL   s    zTraversable.is_dirc                 C   s   dS )z/
        Return True if self is a file
        Nr   r   r   r   r   is_fileR   s    zTraversable.is_filec                 C   s   dS )2
        Return Traversable child in self
        Nr   r   childr   r   r   joinpathX   s    zTraversable.joinpathc                 C   s
   |  |S )r.   )r1   r/   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&   d   s    zTraversable.openc                 C   s   dS )zM
        The base name of this object without any parent references.
        Nr   r   r   r   r   namen   s    zTraversable.name)N)r3   )r   r   r   r   r   r   r#   r)   r+   r   r,   r-   r1   r2   r&   abstractpropertyr    r7   r   r   r   r   r"   1   s    


	r"   c                   @   s>   e Zd ZdZejdd Zdd Zdd Zdd	 Z	d
d Z
dS )TraversableResourceszI
    The required interface for providing traversable
    resources.
    c                 C   s   dS )z3Return a Traversable object for the loaded package.Nr   r   r   r   r   files{   s    zTraversableResources.filesc                 C   s   |   |dS )Nr$   )r:   r1   r&   r   r   r   r   r      s    z"TraversableResources.open_resourcec                 C   s   t |d S Nr   r   r   r   r   r      s    z"TraversableResources.resource_pathc                 C   s   |   | S r;   )r:   r1   r-   r   r   r   r   r      s    z TraversableResources.is_resourcec                 C   s   dd |    D S )Nc                 s   s   | ]}|j V  qd S r;   )r7   ).0itemr   r   r   	<genexpr>   s     z0TraversableResources.contents.<locals>.<genexpr>)r:   r#   r   r   r   r   r      s    zTraversableResources.contentsN)r   r   r   r   r   r   r:   r   r   r   r   r   r   r   r   r9   u   s   
r9   )r   typingr   r   r   _compatr   r   ABCMetar   r"   r9   r   r   r   r   <module>   s   *C