o
    0ήc
                     @   s   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d Zdd	 Zd
d Zdd Zdd ZejdddZejdd Zeejejdd ZdS )    N)UnionOptional   )ResourceReaderTraversable)	wrap_specc                 C   s   t t| S )z3
    Get a Traversable resource from a package
    )from_packageget_package)package r   X/tmp/pip-target-vg8gfxp4/lib/python/pkg_resources/_vendor/importlib_resources/_common.pyfiles   s   r   c                 C   s*   | j }t|jdd}|du rdS ||jS )z?
    Return the package's loader if it's a ResourceReader.
    get_resource_readerN)__spec__getattrloadernamer
   specreaderr   r   r   r      s
   

r   c                 C   s   t | tjr| S t| S )N)
isinstancetypes
ModuleType	importlibimport_module)candr   r   r   resolve*   s   r   c                 C   s(   t | }t|jdu r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
   resolvedr   r   r   r	   /   s   r	   c                 C   s   t | }|j|j}| S )z=
    Return a Traversable object for the given package.

    )r   r   r   r   r   r   r   r   r   r   ;   s   r    c                 c   s    t j|d\}}z0zt||   W t| nt| w ~ t|V  W zt| W d S  ty9   Y d S w zt| W w  tyJ   Y w w )Nsuffix)	tempfilemkstemposwriteclosepathlibPathremoveFileNotFoundError)r   r"   fdraw_pathr   r   r   	_tempfileE   s$   r.   c                 C   s   t | j| jdS )zu
    Given a Traversable object, return that object as a
    path on the local file system in a context manager.
    r!   )r.   
read_bytesr   pathr   r   r   as_fileY   s   r2   c                 c   s    | V  dS )z7
    Degenerate behavior for pathlib.Path objects.
    Nr   r0   r   r   r   _b   s   
r3   )r    )r%   r(   r#   	functools
contextlibr   r   typingr   r   abcr   r   _compatr   r   strPackager   r   r   r	   r   contextmanagerr.   singledispatchr2   registerr)   r3   r   r   r   r   <module>   s.    


