<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
B
    :aD*              	   @   s  d dl m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Zd dl	Z	ddl
mZ ddlmZmZmZ eeZdaG dd deZG dd	 d	eZG d
d deZG dd deZG dd deZG dd deZedee	jeiZyPyd dlZW n e k
r   d dl!ZY nX eeej"< eeej#< eeej$< [W n e e%fk
rV   Y nX dd Z&i Z'dd Z(e)e*dZ+dd Z,dS )    )unicode_literalsN   )DistlibException)cached_propertyget_cache_baseCachec                   s.   e Zd Zd fdd	Zdd Zdd Z  ZS )	ResourceCacheNc                s0   |d krt jt td}tt| | d S )Nzresource-cache)ospathjoinr   strsuperr   __init__)selfbase)	__class__ B/opt/alt/python37/lib/python3.7/site-packages/distlib/resources.pyr      s    zResourceCache.__init__c             C   s   dS )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
   r   r   r   is_stale"   s    	zResourceCache.is_stalec          	   C   s   |j |\}}|dkr|}n~tj| j| ||}tj|}tj|sXt	| tj
|sjd}n| ||}|rt|d}||j W dQ R X |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
   r   r   Zprefix_to_dirdirnameisdirmakedirsexistsr   openwritebytes)r   r   prefixr
   resultr   Zstalefr   r   r   get-   s    
zResourceCache.get)N)__name__
__module____qualname__r   r   r#   __classcell__r   r   )r   r   r      s   r   c               @   s   e Zd Zdd ZdS )ResourceBasec             C   s   || _ || _d S )N)r   name)r   r   r)   r   r   r   r   H   s    zResourceBase.__init__N)r$   r%   r&   r   r   r   r   r   r(   G   s   r(   c               @   s@   e Zd ZdZdZdd Zedd Zedd Zed	d
 Z	dS )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.
    Fc             C   s   | 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)r   r   r   r   	as_streamU   s    zResource.as_streamc             C   s   t d krt a t | S )N)cacher   r#   )r   r   r   r   	file_path^   s    zResource.file_pathc             C   s   | j | S )N)r   	get_bytes)r   r   r   r   r   e   s    zResource.bytesc             C   s   | j | S )N)r   get_size)r   r   r   r   sizei   s    zResource.sizeN)
r$   r%   r&   __doc__is_containerr,   r   r.   r   r1   r   r   r   r   r*   M   s   	r*   c               @   s   e Zd ZdZedd ZdS )ResourceContainerTc             C   s   | j | S )N)r   get_resources)r   r   r   r   	resourcesq   s    zResourceContainer.resourcesN)r$   r%   r&   r3   r   r6   r   r   r   r   r4   n   s   r4   c               @   s   e Zd ZdZejdrdZndZdd Zdd Z	d	d
 Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd ZeejjZdd ZdS )ResourceFinderz4
    Resource finder for file system resources.
    java)z.pycz.pyoz.class)z.pycz.pyoc             C   s.   || _ t|dd | _tjt|dd| _d S )N
__loader____file__ )modulegetattrloaderr	   r
   r   r   )r   r<   r   r   r   r      s    zResourceFinder.__init__c             C   s   t j|S )N)r	   r
   realpath)r   r
   r   r   r   _adjust_path   s    zResourceFinder._adjust_pathc             C   sB   t |trd}nd}||}|d| j tjj| }| |S )N   //r   )	
isinstancer   splitinsertr   r	   r
   r   r@   )r   resource_nameseppartsr!   r   r   r   
_make_path   s    

zResourceFinder._make_pathc             C   s   t j|S )N)r	   r
   r   )r   r
   r   r   r   _find   s    zResourceFinder._findc             C   s
   d |j fS )N)r
   )r   r   r   r   r   r      s    zResourceFinder.get_cache_infoc             C   sD   |  |}| |sd }n&| |r0t| |}n
t| |}||_|S )N)rI   rJ   _is_directoryr4   r*   r
   )r   rF   r
   r!   r   r   r   find   s    



zResourceFinder.findc             C   s   t |jdS )Nrb)r   r
   )r   r   r   r   r   r+      s    zResourceFinder.get_streamc          	   C   s    t |jd
}| S Q R X d S )NrM   )r   r
   read)r   r   r"   r   r   r   r/      s    zResourceFinder.get_bytesc             C   s   t j|jS )N)r	   r
   getsize)r   r   r   r   r   r0      s    zResourceFinder.get_sizec                s*   fdd t  fddt|jD S )Nc                s   | dko|   j S )N__pycache__)endswithskipped_extensions)r"   )r   r   r   allowed   s    z-ResourceFinder.get_resources.<locals>.allowedc                s   g | ]} |r|qS r   r   ).0r"   )rS   r   r   
<listcomp>   s    z0ResourceFinder.get_resources.<locals>.<listcomp>)setr	   listdirr
   )r   r   r   )rS   r   r   r5      s    zResourceFinder.get_resourcesc             C   s   |  |jS )N)rK   r
   )r   r   r   r   r   r3      s    zResourceFinder.is_containerc             c   s   |  |}|d k	r|g}xn|r|d}|V  |jr|j}xH|jD ]>}|sP|}nd||g}|  |}|jrz|| qB|V  qBW qW d S )Nr   rB   )rL   popr3   r)   r6   r   append)r   rF   r   ZtodoZrnamer)   new_nameZchildr   r   r   iterator   s     


zResourceFinder.iteratorN)r$   r%   r&   r2   sysplatform
startswithrR   r   r@   rI   rJ   r   rL   r+   r/   r0   r5   r3   staticmethodr	   r
   r   rK   r[   r   r   r   r   r7   v   s"   r7   c                   s`   e Zd ZdZ fddZdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Z  ZS )ZipResourceFinderz6
    Resource finder for resources in .zip files.
    c                sZ   t t| | | jj}dt| | _t| jdr>| jj| _nt	j
| | _t| j| _d S )Nr   _files)r   r`   r   r>   archivelen
prefix_lenhasattrra   	zipimport_zip_directory_cachesortedindex)r   r<   rb   )r   r   r   r      s    zZipResourceFinder.__init__c             C   s   |S )Nr   )r   r
   r   r   r   r@      s    zZipResourceFinder._adjust_pathc             C   s   || j d  }|| jkrd}nX|r:|d tjkr:|tj }t| j|}y| j| |}W n tk
rt   d}Y nX |st	d|| j
j nt	d|| j
j |S )NTFz_find failed: %r %rz_find worked: %r %r)rd   ra   r	   rG   bisectri   r^   
IndexErrorloggerdebugr>   r    )r   r
   r!   ir   r   r   rJ      s    


zZipResourceFinder._findc             C   s&   | j j}|jdt| d  }||fS )Nr   )r>   rb   r
   rc   )r   r   r    r
   r   r   r   r      s    z ZipResourceFinder.get_cache_infoc             C   s   | j |jS )N)r>   get_datar
   )r   r   r   r   r   r/      s    zZipResourceFinder.get_bytesc             C   s   t | |S )N)ioBytesIOr/   )r   r   r   r   r   r+      s    zZipResourceFinder.get_streamc             C   s   |j | jd  }| j| d S )N   )r
   rd   ra   )r   r   r
   r   r   r   r0      s    zZipResourceFinder.get_sizec             C   s   |j | jd  }|r,|d tjkr,|tj7 }t|}t }t| j|}xV|t| jk r| j| |sjP | j| |d  }|	|
tjdd  |d7 }qJW |S )Nrj   r   r   )r
   rd   r	   rG   rc   rV   rk   ri   r^   addrD   )r   r   r
   Zplenr!   ro   sr   r   r   r5     s    
zZipResourceFinder.get_resourcesc             C   sj   || j d  }|r*|d tjkr*|tj7 }t| j|}y| j| |}W n tk
rd   d}Y nX |S )Nrj   F)rd   r	   rG   rk   ri   r^   rl   )r   r
   ro   r!   r   r   r   rK     s    

zZipResourceFinder._is_directory)r$   r%   r&   r2   r   r@   rJ   r   r/   r+   r0   r5   rK   r'   r   r   )r   r   r`      s   r`   c             C   s   |t t| < d S )N)_finder_registrytype)r>   finder_makerr   r   r   register_finder2  s    ry   c             C   s   | t krt |  }nv| tjkr$t|  tj|  }t|dd}|dkrJtdt|dd}tt|}|dkrxtd|  ||}|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 packager9   zUnable to locate finder for %r)	_finder_cacher\   modules
__import__r=   r   rv   r#   rw   )packager!   r<   r
   r>   rx   r   r   r   r   9  s    


r   Z	__dummy__c             C   sR   d}t |  tj| }tt|}|rNt}tj	
| 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;   )pkgutilZget_importerr\   path_importer_cacher#   rv   rw   _dummy_moduler	   r
   r   r:   r9   )r
   r!   r>   r   r<   r   r   r   finder_for_pathU  s    
r   )-Z
__future__r   rk   rq   loggingr	   r   r\   typesrf   r;   r   utilr   r   r   	getLoggerr$   rm   r-   r   objectr(   r*   r4   r7   r`   rw   zipimporterrv   _frozen_importlib_externalZ_fiImportError_frozen_importlibSourceFileLoader
FileFinderSourcelessFileLoaderAttributeErrorry   r{   r   
ModuleTyper   r   r   r   r   r   r   <module>   sH   
,!ZO



