
    RhS                        d dl Z 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 d dlmZ eeej"                  e   f   Zg dZ G d de j(                        Z G d	 d
e      Ze G d de             Z G d de      Zy)    N)AnyBinaryIOIterableIteratorNoReturnTextOptional)runtime_checkableProtocol)Union)ResourceReaderTraversableTraversableResourcesc                       e Zd ZdZej
                  dedefd       Zej
                  dedefd       Z	ej
                  dede
fd       Zej
                  dee   fd       Zy	)
r   zDAbstract base class for loaders to provide resource reading support.resourcereturnc                     t         )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.
        FileNotFoundErrorselfr   s     ./usr/lib/python3.12/importlib/resources/abc.pyopen_resourcezResourceReader.open_resource   s
          c                     t         )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.
        r   r   s     r   resource_pathzResourceReader.resource_path   s
      r   pathc                     t         )zjReturn True if the named 'path' is a resource.

        Files are resources, directories are not.
        r   r   r   s     r   is_resourcezResourceReader.is_resource,   s
      r   c                     t         )z+Return an iterable of entries in `package`.r   r   s    r   contentszResourceReader.contents4   s
      r   N)__name__
__module____qualname____doc__abcabstractmethodr   r   r   r   boolr    r   strr#    r   r   r   r      s    N	 d 	 x 	  	  	
 d 
 t 
  
  	        	 (3-    r   r   )	metaclassc                       e Zd Zy)TraversalErrorN)r$   r%   r&   r,   r   r   r/   r/   :   s    r   r/   c                   2   e Zd ZdZej
                  ded    fd       ZdefdZ	dde
e   defdZej
                  defd       Zej
                  defd	       Zd
edd fdZdedd fdZej
                  dd       Zeej
                  defd              Zy)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                      y)z3
        Yield Traversable objects in self
        Nr,   r"   s    r   iterdirzTraversable.iterdirH       r   c                 p    | j                  d      5 }|j                         cddd       S # 1 sw Y   yxY w)z0
        Read contents of self as bytes
        rbNopenread)r   strms     r   
read_byteszTraversable.read_bytesN   s/     YYt_ 	99;	 	 	s   ,5Nencodingc                 r    | j                  |      5 }|j                         cddd       S # 1 sw Y   yxY w)z/
        Read contents of self as text
        )r;   Nr6   )r   r;   r9   s      r   	read_textzTraversable.read_textU   s2     YYY) 	T99;	 	 	s   -6c                      y)z4
        Return True if self is a directory
        Nr,   r"   s    r   is_dirzTraversable.is_dir\   r3   r   c                      y)z/
        Return True if self is a file
        Nr,   r"   s    r   is_filezTraversable.is_fileb   r3   r   descendantsc                 L   |s| S t         j                  j                  d t        t        j
                  |      D              }t        |      fd| j                         D        }	 t        |      } |j                  | S # t        $ r t        dt        |            w xY w)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              3   4   K   | ]  }|j                     y wN)parts).0r   s     r   	<genexpr>z'Traversable.joinpath.<locals>.<genexpr>r   s      .
DJJ.
   c              3   B   K   | ]  }|j                   k(  s|  y wrE   name)rG   traversabletargets     r   rH   z'Traversable.joinpath.<locals>.<genexpr>v   s$      
'[=M=MQW=WK
s   z"Target not found during traversal.)	itertoolschainfrom_iterablemappathlibPurePosixPathnextr2   StopIterationr/   listjoinpath)r   rB   namesmatchesmatchrN   s        @r   rX   zTraversable.joinpathh   s     K-- .
#&w'<'<k#J.
 
 e
+/<<>
	ME
 u~~u%%	  	 4fd5k 	s   )B  B#childc                 $    | j                  |      S )z2
        Return Traversable child in self
        )rX   )r   r\   s     r   __truediv__zTraversable.__truediv__   s     }}U##r   c                      y)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kwargss       r   r7   zTraversable.open   r3   r   c                      y)zM
        The base name of this object without any parent references.
        Nr,   r"   s    r   rL   zTraversable.name   r3   r   rE   )r)r$   r%   r&   r'   r(   r)   r   r2   bytesr:   r	   r+   r=   r*   r?   rA   StrPathrX   r^   r7   propertyrL   r,   r   r   r   r   >   s     	-0  
E (3- 3  	  
 	  
&W & &2$ $] $ 	  c   r   r   c                       e Zd ZdZej
                  dd       Zdedej                  fdZ
dedefdZdedefdZdee   fd	Zy
)r   zI
    The required interface for providing traversable
    resources.
    r   c                      y)z3Return a Traversable object for the loaded package.Nr,   r"   s    r   fileszTraversableResources.files   r3   r   r   c                 ^    | j                         j                  |      j                  d      S )Nr5   )rj   rX   r7   r   s     r   r   z"TraversableResources.open_resource   s$    zz|$$X.33D99r   c                     t        |      rE   r   r   s     r   r   z"TraversableResources.resource_path   s    ))r   r   c                 \    | j                         j                  |      j                         S rE   )rj   rX   rA   r   s     r   r    z TraversableResources.is_resource   s"    zz|$$T*2244r   c                 L    d | j                         j                         D        S )Nc              3   4   K   | ]  }|j                     y wrE   rK   )rG   items     r   rH   z0TraversableResources.contents.<locals>.<genexpr>   s     =d		=rI   )rj   r2   r"   s    r   r#   zTraversableResources.contents   s    =djjl&:&:&<==r   N)r   r   )r$   r%   r&   r'   r(   r)   rj   rf   ioBufferedReaderr   r   r   r   r*   r    r   r+   r#   r,   r   r   r   r      sr    
 	B B:g :"2C2C :*c *h *5 5D 5>(3- >r   r   )r(   rq   rO   osrS   typingr   r   r   r   r   r   r	   r
   r   r   r+   PathLikerf   __all__ABCMetar   	Exceptionr/   r   r   r,   r   r   <module>ry      s    
 	  	  N N N .  R[[%%
&
C' s{{ ' T	Y 	 W( W Wt>> >r   