ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python38/lib64/python3.8/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python38/lib64/python3.8/__pycache__/modulefinder.cpython-38.pyc

U

@��dn_�@sdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ejdZejdZ
ejdZejdZeefZejZdZdZdZd	Zd
ZdZdZiZd
d�ZiZdd�Zddd�ZGdd�d�ZGdd�d�Zdd�Z e!dk�rz
e �Z"Wne#k
�re$d�YnXdS)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/python38/lib64/python3.8/modulefinder.py�AddPackagePath(srcCs|t|<dSr)�replacePackageMap)Zoldname�newnamerrr�ReplacePackage3srcCstjj��tjj�||�}|dkr8tdj|d�|d��|jtjjkrVddddt	ffS|jtjj
krtddddtffS|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_pathZkind�file�suffixrrr�_find_module7s*
r:c@seZdZddd�Zdd�ZdS)�ModuleNcCs(||_||_||_d|_i|_i|_dSr)�__name__�__file__�__path__�__code__�globalnames�starimports)�selfrr8rrrr�__init__fszModule.__init__cCsLd|jf}|jdk	r&|d|jf}|jdk	r@|d|jf}|d}|S)Nz	Module(%rz, %r�))r<r=r>)rB�srrr�__repr__ss

zModule.__repr__)NN)r<�
__module__�__qualname__rCrFrrrrr;ds

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|dkrtj}||_i|_i|_||_d|_|dk	r8|ng|_|dk	rJ|ng|_g|_dS)Nr)	�sysr�modules�
badmodules�debug�indent�excludes�
replace_paths�processed_paths)rBrrMrOrPrrrrC~szModuleFinder.__init__cGsV||jkrRt|j�D]}tddd�qt|dd�|D]}tt|�dd�q6t�dS)N�   � ��end)rM�rangerN�print�repr)rB�level�str�args�i�argrrr�msg�s
zModuleFinder.msgcGs,|d}||jkr(|jd|_|j|�dS�Nrr�rMrNr^�rBr[rYrrr�msgin�s
zModuleFinder.msgincGs,|d}||jkr(|jd|_|j|�dSr_r`rarrr�msgout�s
zModuleFinder.msgoutc	CsB|�dd|�t�|�� }ddtf}|�d|||�W5QRXdS)Nr�
run_scriptrr�__main__)r^r4r5r.�load_module)rB�pathname�fp�stuffrrrrd�s
zModuleFinder.run_scriptc	CsTtj�|�\}}tj�|�\}}t�|�� }|dtf}|�||||�W5QRXdS)Nr)r)r�splitr6r4r5r.rf)rBrg�dirrZextrhrirrr�	load_file�s

zModuleFinder.load_filerc	Cs\|�dd||||�|j||d�}|�||�\}}|�||�}|sF|S|jrX|�||�dS)Nr�import_hook�rY)r^�determine_parent�find_head_package�	load_tailr>�ensure_fromlist)	rBr�caller�fromlistrY�parent�q�tail�mrrrrm�szModuleFinder.import_hookcCsN|�dd||�|r|dkr,|�dd�dS|j}|dkr�|jrH|d8}|dkrx|j|}||ksft�|�dd|�|S|�d�|kr�td��d�|�	d�d|��}|j|}|�dd|�|S|jr�|j|}||ks�t�|�dd|�|Sd|k�r>|�
d�}|d|�}|j|}|j|k�s,t�|�dd|�|S|�dd�dS)	N�rorzdetermine_parent -> Nonerzdetermine_parent ->�.zrelative importpath too deep)rbrcr<r>rK�AssertionError�countr �joinrj�rfind)rBrsrYZpnamerur\rrrro�sB





zModuleFinder.determine_parentcCs�|�dd||�d|kr@|�d�}|d|�}||dd�}n|}d}|r\d|j|f}n|}|�|||�}|r�|�dd||f�||fS|r�|}d}|�|||�}|r�|�dd||f�||fS|�dd|�td	|��dS)
Nryrprzrr�%s.%szfind_head_package ->�"raise ImportError: No module named�No module named )rb�findr<�
import_modulercr )rBrurr\�headrwZqnamervrrrrp�s.
zModuleFinder.find_head_packagecCs�|�dd||�|}|r�|�d�}|dkr2t|�}|d|�||dd�}}d|j|f}|�|||�}|s|�dd|�td|��q|�dd	|�|S)
Nryrqrzrrrr�r�zload_tail ->)rbr��lenr<r�rcr )rBrvrwrxr\r�Zmnamerrrrq�s
zModuleFinder.load_tailcCs�|�dd|||�|D]d}|dkrD|sz|�|�}|rz|�||d�qt||�sd|j|f}|�|||�}|std|��qdS)Nryrr�*rrr�)r^�find_all_submodulesrr�hasattrr<r�r )rBrxrt�	recursive�sub�all�subnameZsubmodrrrrrs

zModuleFinder.ensure_fromlistc
	Cs�|js
dSi}g}|tjjdd�7}|tjjdd�7}|tjjdd�7}|jD]�}zt�|�}Wn&tk
r�|�	dd|�YqTYnX|D]R}d}|D]0}t
|�}	||	d�|kr�|d|	�}q�q�|r�|dkr�|||<q�qT|��S)Nrzcan't list directoryrC)r>rr�EXTENSION_SUFFIXES�SOURCE_SUFFIXES�BYTECODE_SUFFIXESr)�listdir�OSErrorr^r��keys)
rBrxrK�suffixesrk�namesr�modZsuff�nrrrr�s.

z ModuleFinder.find_all_submodulescCs
|�dd|||�z|j|}Wntk
r4YnX|�dd|�|S||jkrb|�dd�dS|r�|jdkr�|�dd�dSz|�||o�|j|�\}}}Wn$tk
r�|�ddd�YdSXz|�	||||�}W5|r�|��X|r�t
|||�|�dd|�|S)Nrr�zimport_module ->zimport_module -> None)rbrK�KeyErrorrcrLr>�find_moduler �closerf�setattr)rBZpartname�fqnamerurxrhrgrirrrr�.s:
�
zModuleFinder.import_modulec
Cs(|\}}}|�dd||od|�|tkrF|�||�}|�dd|�|S|tkr`t|��|d�}	n||tkr�z|��}
tj	�
|
|i�Wn:tk
r�}z|�ddt|�|��W5d}~XYnXt
�t|
�dd��}	nd}	|�|�}||_|	�r|j�r|�|	�}	|	|_|�|	|�|�dd|�|S)Nrrfrhzload_module ->�execzraise ImportError: �)rbr+�load_packagercr.�compile�readr2r�_bootstrap_external�
_classify_pycr rZ�marshal�loads�
memoryview�
add_moduler=rP�replace_paths_in_coder?�	scan_code)rBr�rhrg�	file_infor9�mode�typerx�co�data�excrrrrfNs4


zModuleFinder.load_modulecCs<||jkri|j|<|r*d|j||j<nd|j|d<dS)Nr�-)rLr<)rBrrsrrr�_add_badmoduleks


zModuleFinder._add_badmodulecCsB||jkr|�||�dSz|j|||d�Wn~tk
rn}z"|�ddt|��|�||�W5d}~XYn�tk
r�}z"|�ddt|��|�||�W5d}~XYn�X|�r>|D]�}|d|}||jkr�|�||�q�z|j|||g|d�Wq�tk
�r:}z"|�ddt|��|�||�W5d}~XYq�Xq�dS)NrnrzImportError:zSyntaxError:rz)rLr�rmr r^rZ�SyntaxError)rBrrsrtrYr^r��fullnamerrr�_safe_import_hookss,

zModuleFinder._safe_import_hookccs�|j}|j}|j}dd�t�|�D�}t|�D]�\}\}}|tkrTd||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)rBr��coder��constsZopargsr\r�ZopargrYrtrrr�scan_opcodes�s(��
zModuleFinder.scan_opcodescCs�|j}|j}||�D�]F\}}|dkr8|\}d|j|<q|dk�r|\}}d}	|dk	rpd|krbd}	dd�|D�}|j|||dd�|	�r\d}
|jr�|j�|jd	|�}
|
dkr�|j�|�}
|
dk	r�|j�|
j�|j	�|
j	�|
j
dkr�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��sz*ModuleFinder.scan_code.<locals>.<listcomp>rnrzr�)r�r�r@r�r>rK�getr<�updaterAr?ro�RuntimeErrorr�r,r�r�)rBr�rxr��scannerZwhatr[rrtZ	have_starZmmrYru�crrrr��sH





zModuleFinder.scan_codecCs�|�dd||�t�|�}|r"|}|�|�}||_|g|_|jt�|g�|_|�d|j�\}}}z&|�	||||�|�
dd|�|W�S|r�|��XdS)Nrr�rCzload_package ->)rbrr�r�r=r>r
r�r�rfrc)rBr�rgrrxrhZbufrirrrr��s

zModuleFinder.load_packagecCs*||jkr|j|St|�|j|<}|Sr)rKr;)rBr�rxrrrr��s

zModuleFinder.add_modulecCsn|dk	r|jd|}n|}||jkr<|�dd|�t|��|dkrd|tjkr^ddddtffS|j}t||�S)Nrzrzfind_module -> Excludedr)	r<rOrcr rJ�builtin_module_namesr$rr:)rBrrrur�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��PrSrTrxz%-25srzMissing modules:�?z
imported fromz, z7Submodules that appear to be missing, but could also bez#global names in the parent package:N)	rW�sortedrKr�r>r=�any_missing_mayberLr})rBr��keyrx�missing�mayberZmodsrrr�reports0
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�)rBr�r�rrr�any_missing"szModuleFinder.any_missingcCs�g}g}|jD]�}||jkrq|�d�}|dkr<|�|�q||dd�}|d|�}|j�|�}|dk	r�||j|kr�|�|�q�||jkr�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.
        rzrrN)	rLrOr~rrKr�r@rA�sort)rBr�r�rr\r�ZpkgnameZpkgrrrr�*s0	




zModuleFinder.any_missing_maybecCs�tj�|j�}}|jD]*\}}|�|�r||t|�d�}qDq|jr�||jkr�||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�rP�
startswithr�rMrQrcr�listr�rVr,r�r��replace�tuple)rBr�Znew_filenameZoriginal_filenamer��rr�r\rrrr�Xs&
��
z"ModuleFinder.replace_paths_in_code)NrNN)NNr)r)r)r)N)r<rGrHrCr^rbrcrdrlrmrorprqrrr�r�rfr�r�r�r�r�r�r�r�r�r�r�rrrrrI|s2
	

#
 
1
".rIc
Cs�ddl}z|�tjdd�d�\}}Wn2|jk
rX}zt|�WY�dSd}~XYnXd}d}g}g}|D]Z\}}	|dkr�|d}|dkr�d}|dkr�||	�tj�}|dkr�d}|dkrn|�|	�qn|s�d	}
n|d}
tj	dd�}tj	�
|
�|d<||}|dk�r.td
�|D]}tdt|���qt|||�}
|dd�D]`}|dk�r\d}�qF|�r�|dd�d
k�r�|
�
|dd�ddg�n
|
�
|�n
|
�|��qF|
�|
�|
��|
S)Nrrzdmp:qx:z-dz-mz-pz-qz-xzhello.pyzpath:rR���z.*r�)�getoptrJ�argv�errorrWrjr)�pathseprrr*rXrIrmrlrdr�)r�Zoptsr[r^rMZdomodsZaddpathZexclude�o�aZscriptr�item�mfr]rrr�testpsX


r�rez
[interrupted])N)%�__doc__r�Zimportlib._bootstrap_externalr�importlib.machineryr�r)r4rJ�types�warningsZopmaprrrrr�r�r3r.r2r0r+r$r&r
rrrr:r;rIr�r<r��KeyboardInterruptrWrrrr�<module>sL




-w;



Zerion Mini Shell 1.0