Hacked By AnonymousFox

Current Path : /proc/thread-self/root/opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python39/lib64/python3.9/__pycache__/modulefinder.cpython-39.pyc

a

R�fQ_�@s
dZddlZddlZddlZddlZddlZddlZddlZej	dZ
ej	dZej	dZej	dZ
ee
fZejZdZdZdZd	Zd
ZdZdZiZd
d�ZiZdd�Zddd�ZGdd�d�ZGdd�d�Zdd�Zedk�rz
e�Z Wne!�ye"d�Yn0dS)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�1/opt/alt/python39/lib64/python3.9/modulefinder.py�AddPackagePath&srcCs|t|<dSr)�replacePackageMap)Zoldname�newnamerrr�ReplacePackage1srcCstjj��tjj�||�}|dur8tdj|d�|d��|jtjjurVddddt	ffS|jtjj
urtddddtffS|j}|j�
|�r�dtj�|�ddtffSt|jtjj�r�t}n<t|jtjj�r�t}n&t|jtjj�r�t}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!�Zd:d"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd;d,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�ZdS)<�ModuleFinderNrcCsZ|durtj}||_i|_i|_||_d|_|dur8|ng|_|durJ|ng|_g|_dS)Nr)	�sysr�modules�
badmodules�debug�indent�excludes�
replace_paths�processed_paths)rCrrNrPrQrrrrD|szModuleFinder.__init__cGsV||jkrRt|j�D]}tddd�qt|dd�|D]}tt|�dd�q6t�dS)N�   � ��end)rN�rangerO�print�repr)rC�level�str�args�i�argrrr�msg�s
zModuleFinder.msgcGs,|d}||jkr(|jd|_|j|�dS�Nrr�rNrOr_�rCr\rZrrr�msgin�s
zModuleFinder.msgincGs,|d}||jkr(|jd|_|j|�dSr`rarbrrr�msgout�s
zModuleFinder.msgoutcCsV|�dd|�t�|��*}ddtf}|�d|||�Wd�n1sH0YdS)Nr�
run_scriptrr�__main__)r_r4r5r.�load_module)rC�pathname�fp�stuffrrrre�s
zModuleFinder.run_scriptcCshtj�|�\}}tj�|�\}}t�|��*}|dtf}|�||||�Wd�n1sZ0YdS)Nr)r)r�splitr6r4r5r.rg)rCrh�dirrZextrirjrrr�	load_file�s

zModuleFinder.load_filerc	Cs\|�dd||||�|j||d�}|�||�\}}|�||�}|sF|S|jrX|�||�dS)Nr�import_hook�rZ)r_�determine_parent�find_head_package�	load_tailr?�ensure_fromlist)	rCr�caller�fromlistrZ�parent�q�tail�mrrrrn�szModuleFinder.import_hookcCsN|�dd||�|r|dkr,|�dd�dS|j}|dkr�|jrH|d8}|dkrx|j|}||usfJ�|�dd|�|S|�d�|kr�td��d�|�d�d|��}|j|}|�dd|�|S|jr�|j|}||us�J�|�dd|�|Sd|v�r>|�	d�}|d|�}|j|}|j|k�s,J�|�dd|�|S|�dd�dS)	N�rprzdetermine_parent -> Nonerzdetermine_parent ->�.zrelative importpath too deep)
rcrdr=r?rL�countr �joinrk�rfind)rCrtrZZpnamervr]rrrrp�sB





zModuleFinder.determine_parentcCs�|�dd||�d|vr@|�d�}|d|�}||dd�}n|}d}|r\d|j|f}n|}|�|||�}|r�|�dd||f�||fS|r�|}d}|�|||�}|r�|�dd||f�||fS|�dd|�td	|��dS)
Nrzrqr{rr�%s.%szfind_head_package ->�"raise ImportError: No module named�No module named )rc�findr=�
import_modulerdr )rCrvrr]�headrxZqnamerwrrrrq�s.
zModuleFinder.find_head_packagecCs�|�dd||�|}|r�|�d�}|dkr2t|�}|d|�||dd�}}d|j|f}|�|||�}|s|�dd|�td|��q|�dd	|�|S)
Nrzrrr{rrrr�r�zload_tail ->)rcr��lenr=r�rdr )rCrwrxryr]r�Zmnamerrrrr�s
zModuleFinder.load_tailcCs�|�dd|||�|D]d}|dkrD|sz|�|�}|rz|�||d�qt||�sd|j|f}|�|||�}|std|��qdS)Nrzrs�*rrr�)r_�find_all_submodulesrs�hasattrr=r�r )rCryru�	recursive�sub�all�subnameZsubmodrrrrss

zModuleFinder.ensure_fromlistc
	Cs�|js
dSi}g}|tjjdd�7}|tjjdd�7}|tjjdd�7}|jD]�}zt�|�}Wn$ty�|�	dd|�YqTYn0|D]R}d}|D]0}t
|�}	||	d�|kr�|d|	�}q�q�|r�|dkr�|||<q�qT|��S)Nrzcan't list directoryrD)r?rr�EXTENSION_SUFFIXES�SOURCE_SUFFIXES�BYTECODE_SUFFIXESr)�listdir�OSErrorr_r��keys)
rCryrL�suffixesrl�namesr�modZsuff�nrrrr�s.

z ModuleFinder.find_all_submodulescCs|�dd|||�z|j|}Wnty2Yn0|�dd|�|S||jvr`|�dd�dS|r~|jdur~|�dd�dSz|�||o�|j|�\}}}Wn"ty�|�ddd�YdS0z |�||||�}W|r�|�	�n|r�|�	�0|�rt
|||�|�dd|�|S)Nrr�zimport_module ->zimport_module -> None)rcrL�KeyErrorrdrMr?�find_moduler rg�close�setattr)rCZpartname�fqnamervryrirhrjrrrr�,s<

�
�
zModuleFinder.import_modulec
Cs*|\}}}|�dd||od|�|tkrF|�||�}|�dd|�|S|tkr`t|��|d�}	n~|tkr�z|��}
tj	�
|
|i�Wn<ty�}z$|�ddt|�|��WYd}~n
d}~00t
�t|
�dd��}	nd}	|�|�}||_|	�r|j�r|�|	�}	|	|_|�|	|�|�dd|�|S)Nrrgrizload_module ->�execzraise ImportError: �)rcr+�load_packagerdr.�compile�readr2r�_bootstrap_external�
_classify_pycr r[�marshal�loads�
memoryview�
add_moduler>rQ�replace_paths_in_coder@�	scan_code)rCr�rirh�	file_infor:�mode�typery�co�data�excrrrrgLs4


zModuleFinder.load_modulecCs<||jvri|j|<|r*d|j||j<nd|j|d<dS)Nr�-)rMr=)rCrrtrrr�_add_badmoduleis


zModuleFinder._add_badmodulecCsH||jvr|�||�dSz|j|||d�Wn�typ}z*|�ddt|��|�||�WYd}~n�d}~0ty�}z*|�ddt|��|�||�WYd}~n�d}~00|�rD|D]�}|d|}||jvr�|�||�q�z|j|||g|d�Wq�t�y@}z*|�ddt|��|�||�WYd}~q�d}~00q�dS)NrorzImportError:zSyntaxError:r{)rMr�rnr r_r[�SyntaxError)rCrrtrurZr_r��fullnamerrr�_safe_import_hookqs,
 "
zModuleFinder._safe_import_hookccs�|j}|j}|j}dd�t�|�D�}t|�D]�\}\}}|tvrTd||ffVq.|tkr.|dkr.||dd||ddkr�tkr.nq.|||dd}	|||dd}
|	dkr�d|
||ffVq.d|	|
||ffVq.q.dS)	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�ZopargrZrurrr�scan_opcodes�s&��
zModuleFinder.scan_opcodescCs�|j}|j}||�D�]F\}}|dkr8|\}d|j|<q|dk�r|\}}d}	|durpd|vrbd}	dd�|D�}|j|||dd�|	�r\d}
|jr�|j�|jd	|�}
|
dur�|j�|�}
|
dur�|j�|
j�|j	�|
j	�|
j
dur�d|j	|<n
d|j	|<q|d
k�rT|\}}}|�r0|j||||d�n"|j||d�}|j|jd|dd�qt|��q|j
D]"}
t|
t|���rd|�|
|��qddS)Nr�rr�rr�cSsg|]}|dkr|�qS)r�r)r��frrrr���z*ModuleFinder.scan_code.<locals>.<listcomp>ror{r�)r�r�rAr�r?rL�getr=�updaterBr@rp�RuntimeErrorr�r,r�r�)rCr�ryr��scannerZwhatr\rruZ	have_starZmmrZrv�crrrr��sH





zModuleFinder.scan_codecCs�|�dd||�t�|�}|r"|}|�|�}||_|g|_|jt�|g�|_|�d|j�\}}}z2|�||||�|�	dd|�|W|r�|�
�Sn|r�|�
�0dS)Nrr�rDzload_package ->)rcrr�r�r>r?r
r�rgrdr�)rCr�rhrryriZbufrjrrrr��s(

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

zModuleFinder.add_modulecCsn|dur|jd|}n|}||jvr<|�dd|�t|��|durd|tjvr^ddddtffS|j}t||�S)Nr{rzfind_module -> Excludedr)	r=rPrdr rK�builtin_module_namesr$rr;)rCrrrvr�rrrr��s

zModuleFinder.find_modulecCst�tdd�tdd�t|j���}|D]B}|j|}|jrRtddd�ntddd�td||jpnd	�q0|��\}}|r�t�td
�|D]*}t|j|���}td|dd
�|��q�|�rt�tddd�td�|D]*}t|j|���}td|dd
�|��q�dS)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��PrTrUryz%-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��keyry�missing�mayberZmodsrrr�report�s0
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]�}||jvrq|�d�}|dkr<|�|�q||dd�}|d|�}|j�|�}|dur�||j|vr�|�|�q�||jvr�q�|jr�|�|�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)	rMrPr~rrLr�rArB�sort)rCr�r�rr]r�ZpkgnameZpkgrrrr�(s0	




zModuleFinder.any_missing_maybecCs�tj�|j�}}|jD]*\}}|�|�r||t|�d�}qDq|jr�||jvr�||krr|�	dd||f�n|�	dd|f�|j�
|�t|j�}t
t|��D](}t||t|��r�|�||�||<q�|jt|�|d�S)Nrzco_filename %r changed to %rz co_filename %r remains unchanged)r��co_filename)r)r�normpathr�rQ�
startswithr�rNrRrdr�listr�rWr,r�r��replace�tuple)rCr�Znew_filenameZoriginal_filenamer��rr�r]rrrr�Vs&
��
z"ModuleFinder.replace_paths_in_code)NrNN)NNr)r)r)r)N)r=rHrIrDr_rcrdrermrnrprqrrrsr�r�rgr�r�r�r�r�r�r�r�r�r�r�rrrrrJzs2
	

#
 
1
".rJc
Cs�ddl}z|�tjdd�d�\}}Wn0|jyV}zt|�WYd}~dSd}~00d}d}g}g}|D]Z\}}	|dkr�|d}|dkr�d}|dkr�||	�tj�}|dkr�d}|dkrl|�|	�ql|s�d	}
n|d}
tj	dd�}tj	�
|
�|d<||}|dk�r,td
�|D]}tdt|���qt|||�}
|dd�D]`}|dk�rZd}�qD|�r�|dd�d
k�r�|
�
|dd�ddg�n
|
�
|�n
|
�|��qD|
�|
�|
��|
S)Nrrzdmp:qx:z-dz-mz-pz-qz-xzhello.pyzpath:rS���z.*r�)�getoptrK�argv�errorrXrkr)�pathseprrr*rYrJrnrmrer�)r�Zoptsr\r_rNZdomodsZaddpathZexclude�o�aZscriptr�item�mfr^rrr�testnsX


r�rfz
[interrupted])N)#�__doc__r�Zimportlib._bootstrap_externalr�importlib.machineryr�r)r4rKZopmaprrrrr�r�r3r.r2r0r+r$r&r
rrrr;r<rJr�r=r��KeyboardInterruptrXrrrr�<module>sH




-w;



Hacked By AnonymousFox1.0, Coded By AnonymousFox