
    hK                     X   d dl Z d dlZ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	 ddl
mZmZ ddlmZ eej        ef         Zd Zd Zd Zd	 Zd
 Zej        de j        dd            Zej        d             Ze                    ej                  ej        d                         ZdS )    N)UnionOptional   )ResourceReaderTraversable)	wrap_specc                 :    t          t          |                     S )z3
    Get a Traversable resource from a package
    )from_packageget_package)packages    2/usr/lib/python3.11/importlib/resources/_common.pyfilesr      s    
 G,,---    c                 d    | j         }t          |j        dd          }|dS  ||j                  S )z?
    Return the package's loader if it's a ResourceReader.
    get_resource_readerN)__spec__getattrloadernamer   specreaders      r   r   r      s<     DT["7>>F~t6$)r   c                 b    t          | t          j                  r| nt          j        |           S )N)
isinstancetypes
ModuleType	importlibimport_module)cands    r   resolver    *   s*    dE$455X449;RSW;X;XXr   c                 p    t          |           }t          |          j        t          | d          |S )zTake a package name or module object and return the module.

    Raise an exception if the resolved module is not a package.
    Nz is not a package)r    r   submodule_search_locations	TypeError)r   resolveds     r   r   r   /   s>     wH5=7777888Or   c                     t          |           }|j                            |j                  }|                                S )z=
    Return a Traversable object for the given package.

    )r   r   r   r   r   r   s      r   r
   r
   ;   s6    
 WD[,,TY77F<<>>r    )
_os_removec             #   ~  K   t          j        |          \  }}	 	 t          j        | |                        t          j        |           n# t          j        |           w xY w~ t          j        |          V  	  ||           d S # t          $ r Y d S w xY w# 	  ||           w # t          $ r Y w w xY wxY w)Nsuffix)tempfilemkstemposwriteclosepathlibPathFileNotFoundError)r   r*   r'   fdraw_paths        r   	_tempfiler5   E   s       #6222LB	HR"""HRLLLLBHRLLLLl8$$$$$	Jx       	 	 	DD		Jx      	 	 	D	sR   A B A%%B  B 
BBB< B,+B<,
B96B<8B99B<c                 8    t          | j        | j                  S )zu
    Given a Traversable object, return that object as a
    path on the local file system in a context manager.
    r)   )r5   
read_bytesr   paths    r   as_filer:   \   s     T_TY7777r   c              #      K   | V  dS )z7
    Degenerate behavior for pathlib.Path objects.
    N r8   s    r   _r=   e   s       JJJJJr   )r&   )r-   r0   r+   	functools
contextlibr   r   typingr   r   abcr   r   	_adaptersr   r   strPackager   r   r    r   r
   contextmanagerremover5   singledispatchr:   registerr1   r=   r<   r   r   <module>rI      s   				                " " " " " " " " , , , , , , , ,            
 #%
&. . .  "Y Y Y
	 	 	    I    , 8 8 8 	',      r   