AlkantarClanX12

Your IP : 3.138.122.90


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/modulefinder.cpython-310.pyc

o

6��fQ_�@s
dZddlZddlZddlZddlZddlZddlZddlZej	dZ
ej	dZej	dZej	dZ
ee
fZejZdZdZdZd	Zd
ZdZdZiZd
d�ZiZdd�Zddd�ZGdd�d�ZGdd�d�Zdd�Zedkr�ze�Z WdSe!y�e"d�YdSwdS)z3Find modules used by a script, using introspection.�N�
LOAD_CONST�IMPORT_NAME�
STORE_NAME�STORE_GLOBAL������cCst�|g��|�dS�N)�packagePathMap�
setdefault�append)Zpackagename�path�r�3/opt/alt/python310/lib64/python3.10/modulefinder.py�AddPackagePath&srcCs|t|<dSr)�replacePackageMap)Zoldname�newnamerrr�ReplacePackage1srcCstjj��tjj�||�}|durtdj|d�|d��|jtjjur+ddddt	ffS|jtjj
ur:ddddtffS|j}|j�
|�rOdtj�|�ddtffSt|jtjj�rZt}nt|jtjj�ret}nt|jtjj�rpt}nddddtffSt�|�}tj�|�d}|||d|ffS)zDAn importlib reimplementation of imp.find_module (for our purposes).NzNo module named {name!r})�name�����rb)�	importlib�	machinery�
PathFinder�invalidate_caches�	find_spec�ImportError�format�loader�BuiltinImporter�
_C_BUILTIN�FrozenImporter�
_PY_FROZEN�origin�
is_package�osr�dirname�_PKG_DIRECTORY�
isinstance�SourceFileLoader�
_PY_SOURCE�ExtensionFileLoader�_C_EXTENSION�SourcelessFileLoader�_PY_COMPILED�
_SEARCH_ERROR�io�	open_code�splitext)rr�specZ	file_path�kind�file�suffixrrr�_find_module5s*
r;c@seZdZddd�Zdd�ZdS)�ModuleNcCs(||_||_||_d|_i|_i|_dSr)�__name__�__file__�__path__�__code__�globalnames�starimports)�selfrr9rrrr�__init__ds
zModule.__init__cCsLd|jf}|jdur|d|jf}|jdur |d|jf}|d}|S)Nz	Module(%rz, %r�))r=r>r?)rC�srrr�__repr__qs

zModule.__repr__)NN)r=�
__module__�__qualname__rDrGrrrrr<bs

r<c@s�eZdZd6dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zd7dd�Z	d8dd�Z
dd�Zdd�Zd9dd�Z
dd�Zdd�Zdd�Zd d!�Zd8d"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd:d,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�ZdS);�ModuleFinderNrcCsZ|durtj}||_i|_i|_||_d|_|dur|ng|_|dur%|ng|_g|_dS)Nr)	�sysr�modules�
badmodules�debug�indent�excludes�
replace_paths�processed_paths)rCrrNrPrQrrrrD|s
zModuleFinder.__init__cGsZ||jkr+t|j�D]}tddd�q
t|dd�|D]
}tt|�dd�qt�dSdS)N�   � ��end)rN�rangerO�print�repr)rC�level�str�args�i�argrrr�msg�s

�zModuleFinder.msgcGs0|d}||jkr|jd|_|j|�dSdS�Nrr�rNrOr_�rCr\rZrrr�msgin��

�zModuleFinder.msgincGs0|d}||jkr|jd|_|j|�dSdSr`rarbrrr�msgout�rdzModuleFinder.msgoutcCsX|�dd|�t�|��}ddtf}|�d|||�Wd�dS1s%wYdS)Nr�
run_scriptrr�__main__)r_r4r5r.�load_module)rC�pathname�fp�stuffrrrrf�s

"�zModuleFinder.run_scriptcCsjtj�|�\}}tj�|�\}}t�|��}|dtf}|�||||�Wd�dS1s.wYdS)Nr)r)r�splitr6r4r5r.rh)rCri�dirrZextrjrkrrr�	load_file�s
"�zModuleFinder.load_filerc	Cs\|�dd||||�|j||d�}|�||�\}}|�||�}|s#|S|jr,|�||�dS)Nr�import_hook�rZ)r_�determine_parent�find_head_package�	load_tailr?�ensure_fromlist)	rCr�caller�fromlistrZ�parent�q�tail�mrrrro�szModuleFinder.import_hookcCsJ|�dd||�|r|dkr|�dd�dS|j}|dkrb|jr$|d8}|dkr<|j|}||us3J�|�dd|�|S|�d�|krGtd��d�|�d�d|��}|j|}|�dd|�|S|jry|j|}||uspJ�|�dd|�|Sd|vr�|�	d�}|d|�}|j|}|j|ks�J�|�dd|�|S|�dd�dS)	N�rqrzdetermine_parent -> Nonerzdetermine_parent ->�.zrelative importpath too deep)
rcrer=r?rL�countr �joinrl�rfind)rCrurZZpnamerwr]rrrrq�sB




zModuleFinder.determine_parentcCs�|�dd||�d|vr |�d�}|d|�}||dd�}n|}d}|r.d|j|f}n|}|�|||�}|rF|�dd||f�||fS|rb|}d}|�|||�}|rb|�dd||f�||fS|�dd|�td	|��)
Nr{rrr|rr�%s.%szfind_head_package ->�"raise ImportError: No module named�No module named )rc�findr=�
import_modulerer )rCrwrr]�headryZqnamerxrrrrr�s.
zModuleFinder.find_head_packagecCs�|�dd||�|}|rG|�d�}|dkrt|�}|d|�||dd�}}d|j|f}|�|||�}|sE|�dd|�td|��|s|�dd	|�|S)
Nr{rsr|rrr�r�r�zload_tail ->)rcr��lenr=r�rer )rCrxryrzr]r�Zmnamerrrrs�s
�	zModuleFinder.load_tailcCs�|�dd|||�|D]2}|dkr"|s!|�|�}|r!|�||d�qt||�s=d|j|f}|�|||�}|s=td|��qdS)Nr{rt�*rr�r�)r_�find_all_submodulesrt�hasattrr=r�r )rCrzrv�	recursive�sub�all�subnameZsubmodrrrrts
�
��zModuleFinder.ensure_fromlistc
	Cs�|jsdSi}g}|tjjdd�7}|tjjdd�7}|tjjdd�7}|jD]F}zt�|�}WntyC|�	dd|�Yq*w|D])}d}|D]}t
|�}	||	d�|krd|d|	�}nqL|ro|dkro|||<qFq*|��S)Nrzcan't list directoryrD)r?rr�EXTENSION_SUFFIXES�SOURCE_SUFFIXES�BYTECODE_SUFFIXESr)�listdir�OSErrorr_r��keys)
rCrzrL�suffixesrm�namesr�modZsuff�nrrrr�s6
����	z ModuleFinder.find_all_submodulescCs|�dd|||�z|j|}Wn	tyYn
w|�dd|�|S||jvr0|�dd�dS|r?|jdur?|�dd�dSz|�||oG|j|�\}}}Wnty_|�ddd�YdSwz|�||||�}W|rp|�	�n|rx|�	�ww|r�t
|||�|�dd|�|S)Nrr�zimport_module ->zimport_module -> None)rcrL�KeyErrorrerMr?�find_moduler rh�close�setattr)rCZpartname�fqnamerwrzrjrirkrrrr�,sD�

����
�zModuleFinder.import_modulec
Cs|\}}}|�dd||o
d|�|tkr#|�||�}|�dd|�|S|tkr0t|��|d�}	n9|tkrgz|��}
tj	�
|
|i�WntyZ}z|�ddt|�|��d}~wwt
�t|
�dd��}	nd}	|�|�}||_|	r�|jr{|�|	�}	|	|_|�|	|�|�dd|�|S)Nrrhrjzload_module ->�execzraise ImportError: �)rcr+�load_packagerer.�compile�readr2r�_bootstrap_external�
_classify_pycr r[�marshal�loads�
memoryview�
add_moduler>rQ�replace_paths_in_coder@�	scan_code)rCr�rjri�	file_infor:�mode�typerz�co�data�excrrrrhLs8
��

zModuleFinder.load_modulecCs>||jvr
i|j|<|rd|j||j<dSd|j|d<dS)Nr�-)rMr=)rCrrurrr�_add_badmoduleis


zModuleFinder._add_badmodulecCsJ||jvr
|�||�dSz
|j|||d�WnCty9}z|�ddt|��|�||�WYd}~dSd}~wtyZ}z|�ddt|��|�||�WYd}~dSd}~ww|r�|D]C}|d|}||jvrs|�||�q_z|j|||g|d�Wq_ty�}z|�ddt|��|�||�WYd}~q_d}~wwdSdS)NrprzImportError:zSyntaxError:r|)rMr�ror r_r[�SyntaxError)rCrrurvrZr_r��fullnamerrr�_safe_import_hookqs:
���
���zModuleFinder._safe_import_hookccs��|j}|j}|j}dd�t�|�D�}t|�D]`\}\}}|tvr+d||ffVq|tkrx|dkrx||dd||ddkrItkrxnq|||dd}	|||dd}
|	dkrmd|
||ffVn
d|	|
||ffVqqdS)	NcSs"g|]
\}}}|tkr||f�qSr)�EXTENDED_ARG)�.0�_�opr^rrr�
<listcomp>�s�z-ModuleFinder.scan_opcodes.<locals>.<listcomp>�storerrr�absolute_import�relative_import)	�co_code�co_names�	co_consts�disZ_unpack_opargs�	enumerate�	STORE_OPSrr)rCr��coder��constsZopargsr]r�ZopargrZrvrrr�scan_opcodes�s&�0��zModuleFinder.scan_opcodescCs||j}|j}||�D]�\}}|dkr|\}d|j|<q
|dkr~|\}}d}	|dur6d|vr/d}	dd�|D�}|j|||dd�|	r}d}
|jrQ|j�|jd	|�}
|
dur[|j�|�}
|
durx|j�|
j�|j	�|
j	�|
j
durwd|j	|<q
d|j	|<q
|d
kr�|\}}}|r�|j||||d�q
|j||d�}|j|jd|dd�q
t|��|j
D]}
t|
t|��r�|�|
|�q�dS)Nr�rr�rr�cSsg|]}|dkr|�qS)r�r)r��frrrr��sz*ModuleFinder.scan_code.<locals>.<listcomp>rpr|r�)r�r�rAr�r?rL�getr=�updaterBr@rq�RuntimeErrorr�r,r�r�)rCr�rzr��scannerZwhatr\rrvZ	have_starZmmrZrw�crrrr��sP

�
�

��zModuleFinder.scan_codecCs�|�dd||�t�|�}|r|}|�|�}||_|g|_|jt�|g�|_|�d|j�\}}}z|�||||�|�	dd|�|W|rJ|�
�SS|rR|�
�ww)Nrr�rDzload_package ->)rcrr�r�r>r?r
r�rhrer�)rCr�rirrzrjZbufrkrrrr��s$


�
�zModuleFinder.load_packagecCs*||jvr
|j|St|�|j|<}|Sr)rLr<)rCr�rzrrrr��s

zModuleFinder.add_modulecCsn|dur|jd|}n|}||jvr|�dd|�t|��|dur2|tjvr/ddddtffS|j}t||�S)Nr|rzfind_module -> Excludedr)	r=rPrer rK�builtin_module_namesr$rr;)rCrrrwr�rrrr��s


zModuleFinder.find_modulecCst�tdd�tdd�t|j���}|D]!}|j|}|jr)tddd�ntddd�td||jp7d	�q|��\}}|rat�td
�|D]}t|j|���}td|dd
�|��qK|r�t�tddd�td�|D]}t|j|���}td|dd
�|��qrdSdS)z�Print a report to stdout, listing the found modules with their
        paths, as well as modules that are missing, or seem to be missing.
        z
  %-25s %s)�NameZFile)�----r��PrTrUrzz%-25srzMissing modules:�?z
imported fromz, z7Submodules that appear to be missing, but could also bez#global names in the parent package:N)	rX�sortedrLr�r?r>�any_missing_mayberMr~)rCr��keyrz�missing�mayberZmodsrrr�report�s4
�zModuleFinder.reportcCs|��\}}||S)z�Return a list of modules that appear to be missing. Use
        any_missing_maybe() if you want to know which modules are
        certain to be missing, and which *may* be missing.
        )r�)rCr�r�rrr�any_missing szModuleFinder.any_missingcCs�g}g}|jD]V}||jvrq|�d�}|dkr|�|�q||dd�}|d|�}|j�|�}|durX||j|vrC|�|�q||jvrIq|jrR|�|�q|�|�q|�|�q|��|��||fS)a�Return two lists, one with modules that are certainly missing
        and one with modules that *may* be missing. The latter names could
        either be submodules *or* just global names in the package.

        The reason it can't always be determined is that it's impossible to
        tell which names are imported when "from module import *" is done
        with an extension module, short of actually importing it.
        r|rrN)	rMrPrrrLr�rArB�sort)rCr�r�rr]r�ZpkgnameZpkgrrrr�(s0	




zModuleFinder.any_missing_maybecCs�tj�|j�}}|jD]\}}|�|�r!||t|�d�}nq|jrH||jvrH||kr9|�	dd||f�n	|�	dd|f�|j�
|�t|j�}t
t|��D]}t||t|��rg|�||�||<qS|jt|�|d�S)Nrzco_filename %r changed to %rz co_filename %r remains unchanged)r��co_filename)r)r�normpathr�rQ�
startswithr�rNrRrer�listr�rWr,r�r��replace�tuple)rCr�Znew_filenameZoriginal_filenamer��rr�r]rrrr�Vs*
���
�z"ModuleFinder.replace_paths_in_code)NrNN)NNr)r)rr)r=rHrIrDr_rcrerfrnrorqrrrsrtr�r�rhr�r�r�r�r�r�r�r�r�r�r�rrrrrJzs4
	

#
 
1
".rJc
Cs�ddl}z|�tjdd�d�\}}Wn|jy+}zt|�WYd}~dSd}~wwd}d}g}g}|D]-\}}	|dkrB|d}|dkrHd}|dkrT||	�tj�}|dkrZd}|dkrc|�|	�q6|sid	}
n|d}
tj	dd�}tj	�
|
�|d<||}|dkr�td
�|D]	}tdt|��q�t|||�}
|dd�D]+}|dkr�d}q�|r�|dd�d
kr�|
�
|dd�ddg�q�|
�
|�q�|
�|�q�|
�|
�|
��|
S)Nrrzdmp:qx:z-dz-mz-pz-qz-xzhello.pyzpath:rS���z.*r�)�getoptrK�argv�errorrXrlr)�pathseprrr*rYrJrornrfr�)r�Zoptsr\r_rNZdomodsZaddpathZexclude�o�aZscriptr�item�mfr^rrr�testns^��
�
r�rgz
[interrupted]r)#�__doc__r�Zimportlib._bootstrap_externalr�importlib.machineryr�r)r4rKZopmaprrrrr�r�r3r.r2r0r+r$r&r
rrrr;r<rJr�r=r��KeyboardInterruptrXrrrr�<module>sN




-w;��