HEX
Server: Apache
System: Linux sg2plmcpnl492417.prod.sin2.secureserver.net 4.18.0-553.58.1.lve.el8.x86_64 #1 SMP Fri Jul 4 12:07:06 UTC 2025 x86_64
User: nyiet8349bzl (9207396)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/python38/lib/python3.8/site-packages/pip/_vendor/distlib/__pycache__/resources.cpython-38.pyc
U

��eD*�	@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZe�e�ZdaGdd�de�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�Zed�ee	jeiZzPzddlZWne k
�rddl!ZYnXeeej"<eeej#<eeej$<[Wne e%fk
�rVYnXdd�Z&iZ'dd�Z(e�)e*d��Z+dd�Z,dS)�)�unicode_literalsN�)�DistlibException)�cached_property�get_cache_base�Cachecs.eZdZd�fdd�	Zdd�Zdd�Z�ZS)	�
ResourceCacheNcs0|dkrtj�t�td��}tt|��|�dS)Nzresource-cache)�os�path�joinr�str�superr�__init__)�self�base��	__class__��A/tmp/pip-unpacked-wheel-uzdrexel/pip/_vendor/distlib/resources.pyrszResourceCache.__init__cCsdS)z�
        Is the cache stale for the given resource?

        :param resource: The :class:`Resource` being cached.
        :param path: The path of the resource in the cache.
        :return: True if the cache is stale.
        Tr�r�resourcer
rrr�is_stale"s	zResourceCache.is_stalec	Cs�|j�|�\}}|dkr|}n~tj�|j|�|�|�}tj�|�}tj�|�sXt�	|�tj�
|�sjd}n|�||�}|r�t|d��}|�
|j�W5QRX|S)z�
        Get a resource into the cache,

        :param resource: A :class:`Resource` instance.
        :return: The pathname of the resource in the cache.
        NT�wb)�finder�get_cache_infor	r
rr�
prefix_to_dir�dirname�isdir�makedirs�existsr�open�write�bytes)rr�prefixr
�resultr�stale�frrr�get-s
zResourceCache.get)N)�__name__�
__module__�__qualname__rrr'�
__classcell__rrrrrsrc@seZdZdd�ZdS)�ResourceBasecCs||_||_dS�N)r�name)rrr.rrrrHszResourceBase.__init__N)r(r)r*rrrrrr,Gsr,c@s@eZdZdZdZdd�Zedd��Zedd��Zed	d
��Z	dS)�Resourcez�
    A class representing an in-package resource, such as a data file. This is
    not normally instantiated by user code, but rather by a
    :class:`ResourceFinder` which manages the resource.
    FcCs|j�|�S)z�
        Get the resource as a stream.

        This is not a property to make it obvious that it returns a new stream
        each time.
        )r�
get_stream�rrrr�	as_streamUszResource.as_streamcCstdkrt�at�|�Sr-)�cacherr'r1rrr�	file_path^szResource.file_pathcCs|j�|�Sr-)r�	get_bytesr1rrrr"eszResource.bytescCs|j�|�Sr-)r�get_sizer1rrr�sizeisz
Resource.sizeN)
r(r)r*�__doc__�is_containerr2rr4r"r7rrrrr/Ms	

r/c@seZdZdZedd��ZdS)�ResourceContainerTcCs|j�|�Sr-)r�
get_resourcesr1rrr�	resourcesqszResourceContainer.resourcesN)r(r)r*r9rr<rrrrr:nsr:c@s�eZdZdZej�d�rdZndZdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zeejj�Zdd�ZdS)�ResourceFinderz4
    Resource finder for file system resources.
    �java)�.pyc�.pyoz.class)r?r@cCs.||_t|dd�|_tj�t|dd��|_dS)N�
__loader__�__file__�)�module�getattr�loaderr	r
rr)rrDrrrr�szResourceFinder.__init__cCstj�|�Sr-)r	r
�realpath�rr
rrr�_adjust_path�szResourceFinder._adjust_pathcCsBt|t�rd}nd}|�|�}|�d|j�tjj|�}|�|�S)N�/�/r)	�
isinstancer"�split�insertrr	r
rrI)r�
resource_name�sep�partsr$rrr�
_make_path�s

zResourceFinder._make_pathcCstj�|�Sr-)r	r
rrHrrr�_find�szResourceFinder._findcCs
d|jfSr-)r
�rrrrrr�szResourceFinder.get_cache_infocCsD|�|�}|�|�sd}n&|�|�r0t||�}n
t||�}||_|Sr-)rRrS�
_is_directoryr:r/r
)rrOr
r$rrr�find�s



zResourceFinder.findcCst|jd�S�N�rb)r r
rTrrrr0�szResourceFinder.get_streamc
Cs,t|jd��}|��W5QR�SQRXdSrW)r r
�read)rrr&rrrr5�szResourceFinder.get_bytescCstj�|j�Sr-)r	r
�getsizerTrrrr6�szResourceFinder.get_sizecs*�fdd��t�fdd�t�|j�D��S)Ncs|dko|��j�S)N�__pycache__)�endswith�skipped_extensions)r&r1rr�allowed�s
�z-ResourceFinder.get_resources.<locals>.allowedcsg|]}�|�r|�qSrr)�.0r&)r^rr�
<listcomp>�sz0ResourceFinder.get_resources.<locals>.<listcomp>)�setr	�listdirr
rTr)r^rrr;�szResourceFinder.get_resourcescCs|�|j�Sr-)rUr
rTrrrr9�szResourceFinder.is_containerccs�|�|�}|dk	r�|g}|r�|�d�}|V|jr|j}|jD]>}|sL|}nd�||g�}|�|�}|jrv|�|�q>|Vq>qdS)NrrK)rV�popr9r.r<r�append)rrOr�todo�rnamer.�new_name�childrrr�iterator�s 



zResourceFinder.iteratorN)r(r)r*r8�sys�platform�
startswithr]rrIrRrSrrVr0r5r6r;r9�staticmethodr	r
rrUrirrrrr=vs"r=cs`eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Z�Z
S)�ZipResourceFinderz6
    Resource finder for resources in .zip files.
    csZtt|��|�|jj}dt|�|_t|jd�r>|jj|_nt	j
||_t|j�|_dS)Nr�_files)
r
rnrrF�archive�len�
prefix_len�hasattrro�	zipimport�_zip_directory_cache�sorted�index)rrDrprrrr�szZipResourceFinder.__init__cCs|Sr-rrHrrrrI�szZipResourceFinder._adjust_pathcCs�||jd�}||jkrd}nX|r:|dtjkr:|tj}t�|j|�}z|j|�|�}Wntk
rtd}YnX|s�t�	d||j
j�nt�	d||j
j�|S)NT���Fz_find failed: %r %rz_find worked: %r %r)rrror	rP�bisectrwrl�
IndexError�logger�debugrFr#)rr
r$�irrrrS�s


zZipResourceFinder._findcCs&|jj}|jdt|�d�}||fS)Nr)rFrpr
rq)rrr#r
rrrr�sz ZipResourceFinder.get_cache_infocCs|j�|j�Sr-)rF�get_datar
rTrrrr5�szZipResourceFinder.get_bytescCst�|�|��Sr-)�io�BytesIOr5rTrrrr0�szZipResourceFinder.get_streamcCs|j|jd�}|j|dS)N�)r
rrrorrrrr6�szZipResourceFinder.get_sizecCs�|j|jd�}|r,|dtjkr,|tj7}t|�}t�}t�|j|�}|t|j�kr�|j|�|�shq�|j||d�}|�	|�
tjd�d�|d7}qH|S)Nrxrr)r
rrr	rPrqraryrwrl�addrM)rrr
�plenr$r}�srrrr;s

zZipResourceFinder.get_resourcescCsj||jd�}|r*|dtjkr*|tj7}t�|j|�}z|j|�|�}Wntk
rdd}YnX|S)NrxF)rrr	rPryrwrlrz)rr
r}r$rrrrUs

zZipResourceFinder._is_directory)r(r)r*r8rrIrSrr5r0r6r;rUr+rrrrrn�srncCs|tt|�<dSr-)�_finder_registry�type)rF�finder_makerrrr�register_finder2sr�cCs�|tkrt|}nv|tjkr$t|�tj|}t|dd�}|dkrJtd��t|dd�}t�t|��}|dkrxtd|��||�}|t|<|S)z�
    Return a resource finder for a package.
    :param package: The name of the package.
    :return: A :class:`ResourceFinder` instance for the package.
    �__path__Nz8You cannot get a finder for a module, only for a packagerAzUnable to locate finder for %r)	�
_finder_cacherj�modules�
__import__rErr�r'r�)�packager$rDr
rFr�rrrr9s


r�	__dummy__cCsRd}t�|�tj�|�}t�t|��}|rNt}tj	�
|d�|_||_||�}|S)z�
    Return a resource finder for a path, which should represent a container.

    :param path: The path.
    :return: A :class:`ResourceFinder` instance for the path.
    NrC)
�pkgutil�get_importerrj�path_importer_cacher'r�r��
_dummy_moduler	r
rrBrA)r
r$rFrrDrrr�finder_for_pathUs
r�)-�
__future__rryr�loggingr	r�rj�typesrtrCr�utilrrr�	getLoggerr(r{r3r�objectr,r/r:r=rnr��zipimporterr��_frozen_importlib_externalZ_fi�ImportError�_frozen_importlib�SourceFileLoader�
FileFinder�SourcelessFileLoader�AttributeErrorr�r�r�
ModuleTyperr�r�rrrr�<module>sN
,!ZO�