HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/pip/_vendor/distlib/__pycache__/resources.cpython-37.pyc
B

L��gD*�	@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	jeiZyPy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-hv55ucu3/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�WdQRX|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__rr)rrrsrc@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�|�S)N)�cacherr%)rrrr�	file_path^szResource.file_pathcCs|j�|�S)N)r�	get_bytes)rrrrr eszResource.bytescCs|j�|�S)N)r�get_size)rrrr�sizeisz
Resource.sizeN)
r&r'r(�__doc__�is_containerr.rr0r r3rrrrr,Ms	r,c@seZdZdZedd��ZdS)�ResourceContainerTcCs|j�|�S)N)r�
get_resources)rrrr�	resourcesqszResourceContainer.resourcesN)r&r'r(r5rr8rrrrr6nsr6c@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)z.pycz.pyoz.class)z.pycz.pyocCs.||_t|dd�|_tj�t|dd��|_dS)N�
__loader__�__file__�)�module�getattr�loaderr	r
rr)rr>rrrr�szResourceFinder.__init__cCstj�|�S)N)r	r
�realpath)rr
rrr�_adjust_path�szResourceFinder._adjust_pathcCsBt|t�rd}nd}|�|�}|�d|j�tjj|�}|�|�S)N�/�/r)	�
isinstancer �split�insertrr	r
rrB)r�
resource_name�sep�partsr"rrr�
_make_path�s

zResourceFinder._make_pathcCstj�|�S)N)r	r
r)rr
rrr�_find�szResourceFinder._findcCs
d|jfS)N)r
)rrrrrr�szResourceFinder.get_cache_infocCsD|�|�}|�|�sd}n&|�|�r0t||�}n
t||�}||_|S)N)rKrL�
_is_directoryr6r,r
)rrHr
r"rrr�find�s



zResourceFinder.findcCst|jd�S)N�rb)rr
)rrrrrr-�szResourceFinder.get_streamc	Cs t|jd��
}|��SQRXdS)NrO)rr
�read)rrr$rrrr1�szResourceFinder.get_bytescCstj�|j�S)N)r	r
�getsize)rrrrrr2�szResourceFinder.get_sizecs*�fdd��t�fdd�t�|j�D��S)Ncs|dko|��j�S)N�__pycache__)�endswith�skipped_extensions)r$)rrr�allowed�sz-ResourceFinder.get_resources.<locals>.allowedcsg|]}�|�r|�qSrr)�.0r$)rUrr�
<listcomp>�sz0ResourceFinder.get_resources.<locals>.<listcomp>)�setr	�listdirr
)rrr)rUrrr7�szResourceFinder.get_resourcescCs|�|j�S)N)rMr
)rrrrrr5�szResourceFinder.is_containerccs�|�|�}|dk	r�|g}xn|r�|�d�}|V|jr|j}xH|jD]>}|sP|}nd�||g�}|�|�}|jrz|�|�qB|VqBWqWdS)NrrD)rN�popr5r+r8r�append)rrHr�todo�rnamer+�new_name�childrrr�iterator�s 


zResourceFinder.iteratorN)r&r'r(r4�sys�platform�
startswithrTrrBrKrLrrNr-r1r2r7r5�staticmethodr	r
rrMr`rrrrr9vs"r9cs`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
rerr@�archive�len�
prefix_len�hasattrrf�	zipimport�_zip_directory_cache�sorted�index)rr>rg)rrrr�szZipResourceFinder.__init__cCs|S)Nr)rr
rrrrB�szZipResourceFinder._adjust_pathcCs�||jd�}||jkrd}nX|r:|dtjkr:|tj}t�|j|�}y|j|�|�}Wntk
rtd}YnX|s�t�	d||j
j�nt�	d||j
j�|S)NT���Fz_find failed: %r %rz_find worked: %r %r)rirfr	rI�bisectrnrc�
IndexError�logger�debugr@r!)rr
r"�irrrrL�s


zZipResourceFinder._findcCs&|jj}|jdt|�d�}||fS)Nr)r@rgr
rh)rrr!r
rrrr�sz ZipResourceFinder.get_cache_infocCs|j�|j�S)N)r@�get_datar
)rrrrrr1�szZipResourceFinder.get_bytescCst�|�|��S)N)�io�BytesIOr1)rrrrrr-�szZipResourceFinder.get_streamcCs|j|jd�}|j|dS)N�)r
rirf)rrr
rrrr2�szZipResourceFinder.get_sizecCs�|j|jd�}|r,|dtjkr,|tj7}t|�}t�}t�|j|�}xV|t|j�kr�|j|�|�sjP|j||d�}|�	|�
tjd�d�|d7}qJW|S)Nrorr)r
rir	rIrhrXrprnrc�addrF)rrr
�plenr"rt�srrrr7s
zZipResourceFinder.get_resourcescCsj||jd�}|r*|dtjkr*|tj7}t�|j|�}y|j|�|�}Wntk
rdd}YnX|S)NroF)rir	rIrprnrcrq)rr
rtr"rrrrMs

zZipResourceFinder._is_directory)r&r'r(r4rrBrLrr1r-r2r7rMr)rr)rrre�srecCs|tt|�<dS)N)�_finder_registry�type)r@�finder_makerrrr�register_finder2srcCs�|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 packager;zUnable to locate finder for %r)	�
_finder_cachera�modules�
__import__r?rr|r%r})�packager"r>r
r@r~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.
    Nr=)
�pkgutil�get_importerra�path_importer_cacher%r|r}�
_dummy_moduler	r
rr<r;)r
r"r@rr>rrr�finder_for_pathUs
r�)-�
__future__rrprv�loggingr	r�ra�typesrkr=r�utilrrr�	getLoggerr&rrr/r�objectr*r,r6r9rer}�zipimporterr|�_frozen_importlib_externalZ_fi�ImportError�_frozen_importlib�SourceFileLoader�
FileFinder�SourcelessFileLoader�AttributeErrorrr�r�
ModuleTyperr�r�rrrr�<module>sH
,!ZO