a
    3jZH                     @   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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 d dlmZ d dlmZ d dlmZ g dZG dd	 d	eZG d
d deddZG dd dejZG dd dZG dd dZG dd deZ G dd dZ!G dd dZ"G dd de Z#G dd deZ$dd Z%d d! Z&d"d# Z'd$d% Z(d&d' Z)d(d) Z*d*d+ Z+dS ),    N)ConfigParser)suppress)import_module)MetaPathFinder)starmap)
DistributionDistributionFinderPackageNotFoundErrordistributiondistributionsentry_pointsfilesmetadatarequiresversionc                   @   s   e Zd ZdS )r	   N)__name__
__module____qualname__ r   r   N/www/server/python_manager/versions/3.9.10/lib/python3.9/importlib/metadata.pyr	   %   s   r	   c                   @   sj   e Zd ZedZdd Zedd Zedd Z	edd	 Z
ed
d Zedd Zdd Zdd ZdS )
EntryPointzF(?P<module>[\w.]+)\s*(:\s*(?P<attr>[\w.]+))?\s*(?P<extras>\[.*\])?\s*$c                 C   sD   | j | j}t|d}td |dp,dd}tt	||S )Nmoduleattr .)
patternmatchvaluer   groupfiltersplit	functoolsreducegetattr)selfr   r   attrsr   r   r   loadG   s    zEntryPoint.loadc                 C   s   | j | j}|dS )Nr   r   r   r   r   r$   r   r   r   r   r   Q   s    zEntryPoint.modulec                 C   s   | j | j}|dS )Nr   r'   r(   r   r   r   r   V   s    zEntryPoint.attrc                 C   s(   | j | j}ttd|dp"dS )Nz\w+extrasr   )r   r   r   listrefinditerr   r(   r   r   r   r)   [   s    zEntryPoint.extrasc                    s    fdd  D S )Nc                    s,   g | ]$} |D ]\}} |||qqS r   items).0r   namer   clsconfigr   r   
<listcomp>b   s   z+EntryPoint._from_config.<locals>.<listcomp>)sectionsr1   r   r1   r   _from_config`   s    zEntryPoint._from_configc                 C   sL   t dd}t|_z|| W n" ty@   |t| Y n0 t	|S )N=)Z
delimiters)
r   strZoptionxformZread_stringAttributeErrorZreadfpioStringIOr   r6   )r2   textr3   r   r   r   
_from_texth   s    
zEntryPoint._from_textc                 C   s   t | j| fS N)iterr0   r$   r   r   r   __iter__t   s    zEntryPoint.__iter__c                 C   s   | j | j| j| jffS r>   )	__class__r0   r   r   r@   r   r   r   
__reduce__z   s    zEntryPoint.__reduce__N)r   r   r   r+   compiler   r&   propertyr   r   r)   classmethodr6   r=   rA   rC   r   r   r   r   r   )   s    	





r   ZEntryPointBasezname value groupc                   @   s&   e Zd Zd	ddZdd Zdd ZdS )
PackagePathutf-8c                 C   s<   |   j|d}| W  d    S 1 s.0    Y  d S )Nencodinglocateopenread)r$   rJ   streamr   r   r   	read_text   s    zPackagePath.read_textc                 C   s:   |   d}| W  d    S 1 s,0    Y  d S )NrbrK   )r$   rO   r   r   r   read_binary   s    zPackagePath.read_binaryc                 C   s   | j | S r>   )distlocate_filer@   r   r   r   rL      s    zPackagePath.locateN)rH   )r   r   r   rP   rR   rL   r   r   r   r   rG      s   
rG   c                   @   s   e Zd Zdd Zdd ZdS )FileHashc                 C   s   | d\| _}| _d S )Nr7   )	partitionmoder   )r$   spec_r   r   r   __init__   s    zFileHash.__init__c                 C   s   d | j| jS )Nz<FileHash mode: {} value: {}>)formatrW   r   r@   r   r   r   __repr__   s    zFileHash.__repr__N)r   r   r   rZ   r\   r   r   r   r   rU      s   rU   c                   @   s   e Zd Zejdd Zejdd Zedd Zedd Z	e
d	d
 Ze
dd Zed)ddZedd Zedd Zedd Zedd Zdd Zdd Zedd Zdd Zd d! Zed"d# Ze
d$d% Ze
d&d' Zd(S )*r   c                 C   s   d S r>   r   r$   filenamer   r   r   rP      s    zDistribution.read_textc                 C   s   d S r>   r   r$   pathr   r   r   rT      s    zDistribution.locate_filec                 C   sH   |   D ]2}|tj|d}tt|d }|d ur|  S qt|d S )Nr0   )_discover_resolversr   Contextnextr?   r	   )r2   r0   resolverZdistsrS   r   r   r   	from_name   s    

zDistribution.from_namec                    sN   | dd   r|rtd p.tjf i | tj fdd|  D S )Ncontextz cannot accept context and kwargsc                 3   s   | ]}| V  qd S r>   r   )r/   re   rg   r   r   	<genexpr>   s   z(Distribution.discover.<locals>.<genexpr>)pop
ValueErrorr   rc   	itertoolschainfrom_iterablerb   )r2   kwargsr   rh   r   discover   s    
zDistribution.discoverc                 C   s   t t| S r>   )PathDistributionpathlibPath)r`   r   r   r   at   s    zDistribution.atc                  C   s   dd t jD } td | S )Nc                 s   s   | ]}t |d dV  qdS )find_distributionsN)r#   )r/   finderr   r   r   ri      s   z3Distribution._discover_resolvers.<locals>.<genexpr>)sys	meta_pathr   )Zdeclaredr   r   r   rb      s    z Distribution._discover_resolversr   c                 C   s@   ddl m}m} ||}tj|j||d}tt|	|S )Nr   )buildmeta)Z
source_dirsystem)
Zpep517ry   rz   Zcompat_systemr!   partialrq   zipfilers   Zbuild_as_zip)r2   rootry   rz   r{   Zbuilderr   r   r   _local   s    
zDistribution._localc                 C   s(   |  dp|  dp|  d}t|S )NZMETADATAzPKG-INFOr   )rP   emailZmessage_from_stringr$   r<   r   r   r   r      s    
zDistribution.metadatac                 C   s
   | j d S )NZVersion)r   r@   r   r   r   r      s    zDistribution.versionc                 C   s   t | dS )Nzentry_points.txt)r   r=   rP   r@   r   r   r   r     s    zDistribution.entry_pointsc                    s6      p  }d fdd	}|o4tt|t|S )Nc                    s6   t | }|rt|nd |_|r&t|nd |_ |_|S r>   )rG   rU   hashintsizerS   )r0   r   Zsize_strresultr@   r   r   	make_file  s
    z%Distribution.files.<locals>.make_file)NN)_read_files_distinfo_read_files_egginfor*   r   csvreader)r$   Z
file_linesr   r   r@   r   r     s    zDistribution.filesc                 C   s   |  d}|o| S )NZRECORD)rP   
splitlinesr   r   r   r   r     s    
z!Distribution._read_files_distinfoc                 C   s   |  d}|otdj| S )NzSOURCES.txtz"{}")rP   mapr[   r   r   r   r   r   r   $  s    
z Distribution._read_files_egginfoc                 C   s   |   p|  }|ot|S r>   )_read_dist_info_reqs_read_egg_info_reqsr*   )r$   Zreqsr   r   r   r   ,  s    zDistribution.requiresc                 C   s   | j dS )NzRequires-Dist)r   Zget_allr@   r   r   r   r   2  s    z!Distribution._read_dist_info_reqsc                 C   s   |  d}|o| |S )Nzrequires.txt)rP   _deps_from_requires_text)r$   sourcer   r   r   r   5  s    
z Distribution._read_egg_info_reqsc                 C   s4   |  | }dd t|tdD }| |S )Nc                 S   s&   i | ]\}}|t ttd |qS )line)r*   r   operator
itemgetter)r/   sectionresultsr   r   r   
<dictcomp><  s   z9Distribution._deps_from_requires_text.<locals>.<dictcomp>r   )_read_sectionsr   rl   groupbyr   r   %_convert_egg_info_reqs_to_simple_reqs)r2   r   Zsection_pairsr5   r   r   r   r   9  s
    z%Distribution._deps_from_requires_textc                 c   s<   d }t d | D ](}td|}|r.|d}qt V  qd S )Nz	\[(.*)\]$   )r   r+   r   r   locals)linesr   r   Zsection_matchr   r   r   r   C  s    
zDistribution._read_sectionsc                 #   sV   dd   fdd}dd }|   D ],\}}|D ]}||}|| || V  q0q$d S )Nc                 S   s   | odj | dS )Nzextra == "{name}"ra   )r[   ra   r   r   r   make_conditionX  s    zJDistribution._convert_egg_info_reqs_to_simple_reqs.<locals>.make_conditionc                    sX   | pd} |  d\}}}|r,|r,d| d}ttd | |g}|rTdd| S dS )Nr   :()z; z and )rV   r*   r   join)r   extrasepZmarkersZ
conditionsr   r   r   quoted_marker[  s    zIDistribution._convert_egg_info_reqs_to_simple_reqs.<locals>.quoted_markerc                 S   s   dd| v  S )N @r   )Zreqr   r   r   url_req_spacec  s    zIDistribution._convert_egg_info_reqs_to_simple_reqs.<locals>.url_req_spacer-   )r5   r   r   r   ZdepsZdepspacer   r   r   r   M  s    z2Distribution._convert_egg_info_reqs_to_simple_reqsN)r   )r   r   r   abcabstractmethodrP   rT   rF   rf   rp   staticmethodrt   rb   r   rE   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      sD   












	
	r   c                   @   s.   e Zd ZG dd dZeje fddZdS )r   c                   @   s$   e Zd ZdZdd Zedd ZdS )zDistributionFinder.ContextNc                 K   s   t | | d S r>   )varsupdate)r$   ro   r   r   r   rZ     s    z#DistributionFinder.Context.__init__c                 C   s   t | dtjS )Nr`   )r   getrw   r`   r@   r   r   r   r`     s    zDistributionFinder.Context.path)r   r   r   r0   rZ   rE   r`   r   r   r   r   rc   v  s   rc   c                 C   s   d S r>   r   )r$   rg   r   r   r   ru     s    z%DistributionFinder.find_distributionsN)r   r   r   rc   r   r   ru   r   r   r   r   r   q  s   r   c                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )FastPathc                 C   s   || _ tj| j  | _d S r>   )r~   osr`   basenamelowerbase)r$   r~   r   r   r   rZ     s    zFastPath.__init__c                 C   s   t | j|S r>   )rr   rs   r~   )r$   childr   r   r   joinpath  s    zFastPath.joinpathc                 C   sl   t t  t| jpdW  d    S 1 s.0    Y  t t |  W  d    S 1 s^0    Y  g S )Nr   )r   	Exceptionr   listdirr~   zip_childrenr@   r   r   r   children  s
    
.
&zFastPath.childrenc                 C   s2   t | j}|j }|j| _tdd |D S )Nc                 s   s    | ]}| tjd d V  qdS )r   r   N)r    	posixpathr   )r/   r   r   r   r   ri     s   z(FastPath.zip_children.<locals>.<genexpr>)r}   rs   r~   Znamelistr   dictfromkeys)r$   Zzip_pathnamesr   r   r   r     s    

zFastPath.zip_childrenc                 C   s&   | j }||jkp$||jo$|dS )N.egg)r   versionless_egg_name
startswithprefixendswith)r$   searchr   r   r   r   is_egg  s
    
zFastPath.is_eggc                 c   sZ   |   D ]L}| }||jv sH||jr6||jsH| |r|dkr| |V  qd S )Nzegg-info)	r   r   exact_matchesr   r   r   suffixesr   r   )r$   r0   r   Zn_lowr   r   r   r     s    


zFastPath.searchN)	r   r   r   rZ   r   r   r   r   r   r   r   r   r   r     s   
r   c                   @   s2   e Zd ZdZdZdZdgdd ZdZdd ZdS )Preparedr   )z
.dist-infoz	.egg-infoNr   c                    sV   | _ |d u rd S | dd _ jd  _ fdd jD  _ jd  _d S )N-rY   c                    s   g | ]} j | qS r   )
normalized)r/   suffixr@   r   r   r4     s   z%Prepared.__init__.<locals>.<listcomp>r   )r0   r   replacer   r   r   r   r   )r$   r0   r   r@   r   rZ     s    
zPrepared.__init__)	r   r   r   r   r   r   r   r   rZ   r   r   r   r   r     s   r   c                   @   s,   e Zd Zee fddZedd ZdS )MetadataPathFinderc                 C   s   |  |j|j}tt|S r>   )_search_pathsr0   r`   r   rq   )r2   rg   foundr   r   r   ru     s    
z%MetadataPathFinder.find_distributionsc                    s    t j fddtt|D S )Nc                 3   s   | ]}| t V  qd S r>   )r   r   )r/   r`   ra   r   r   ri     s   z3MetadataPathFinder._search_paths.<locals>.<genexpr>)rl   rm   rn   r   r   )r2   r0   pathsr   ra   r   r     s    z MetadataPathFinder._search_pathsN)r   r   r   rF   r   rc   ru   r   r   r   r   r   r     s   r   c                   @   s.   e Zd Zdd Zdd Zejje_dd ZdS )rq   c                 C   s
   || _ d S r>   )_pathr_   r   r   r   rZ     s    zPathDistribution.__init__c                 C   sH   t ttttt$ | j|jddW  d    S 1 s:0    Y  d S )NrH   rI   )	r   FileNotFoundErrorIsADirectoryErrorKeyErrorNotADirectoryErrorPermissionErrorr   r   rP   r]   r   r   r   rP     s    zPathDistribution.read_textc                 C   s   | j j| S r>   )r   parentr_   r   r   r   rT     s    zPathDistribution.locate_fileN)r   r   r   rZ   rP   r   __doc__rT   r   r   r   r   rq     s   
rq   c                 C   s
   t | S r>   )r   rf   Zdistribution_namer   r   r   r
     s    r
   c                  K   s   t jf i | S r>   )r   rp   )ro   r   r   r   r     s    r   c                 C   s   t | jS r>   )r   rf   r   r   r   r   r   r      s    r   c                 C   s
   t | jS r>   )r
   r   r   r   r   r   r   )  s    r   c                  C   sH   t jdd t D } td}t| |d}t ||}dd |D S )Nc                 s   s   | ]}|j V  qd S r>   )r   )r/   rS   r   r   r   ri   8  s   zentry_points.<locals>.<genexpr>r   )keyc                 S   s   i | ]\}}|t |qS r   )tuple)r/   r   epsr   r   r   r   =  s   z entry_points.<locals>.<dictcomp>)rl   rm   rn   r   r   
attrgettersortedr   )r   Zby_groupZorderedZgroupedr   r   r   r   3  s    
r   c                 C   s
   t | jS r>   )r
   r   r   r   r   r   r   C  s    r   c                 C   s
   t | jS r>   )r
   r   r   r   r   r   r   L  s    r   ),r:   r   r+   r   r   rw   r   rr   r}   r   r!   rl   r   collectionsconfigparserr   
contextlibr   	importlibr   importlib.abcr   r   __all__ModuleNotFoundErrorr	   
namedtupler   PurePosixPathrG   rU   r   r   r   r   r   rq   r
   r   r   r   r   r   r   r   r   r   r   <module>   sN   

X Y/0		
	