AlkantarClanX12

Your IP : 3.142.131.51


Current Path : /proc/self/root/usr/lib64/python3.6/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib64/python3.6/__pycache__/modulefinder.cpython-36.pyc

3


 \�Y�@sdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
e
j��e
jde
�ddlZWdQRXejdZejdZejdZejdZeefZejZiZdd	�ZiZd
d�ZGdd
�d
�ZGdd�d�Zdd�Zedk�ry
e�ZWnek
�re d�YnXdS)z3Find modules used by a script, using introspection.�N�ignore�
LOAD_CONST�IMPORT_NAME�
STORE_NAME�STORE_GLOBALcCstj|g�j|�dS)N)�packagePathMap�
setdefault�append)Zpackagename�path�r�$/usr/lib64/python3.6/modulefinder.py�AddPackagePath sr
cCs|t|<dS)N)�replacePackageMap)Zoldname�newnamerrr�ReplacePackage+src@seZdZddd�Zdd�ZdS)�ModuleNcCs(||_||_||_d|_i|_i|_dS)N)�__name__�__file__�__path__�__code__�globalnames�starimports)�self�name�filer
rrr�__init__1szModule.__init__cCsLd|jf}|jdk	r&|d|jf}|jdk	r@|d|jf}|d}|S)Nz	Module(%rz, %r�))rrr)r�srrr�__repr__>s

zModule.__repr__)NN)r�
__module__�__qualname__rrrrrrr/s

rc@s�eZdZddggfdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zd7dd�Z	d9dd�Z
dd�Zdd�Zd:dd�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)>�ModuleFinderNrcCsB|dkrtj}||_i|_i|_||_d|_||_||_g|_dS)Nr)	�sysr
�modules�
badmodules�debug�indent�excludes�
replace_paths�processed_paths)rr
r%r'r(rrrrIszModuleFinder.__init__cGs^||jkrZxt|j�D]}tddd�qWt|dd�x|D]}tt|�dd�q<Wt�dS)Nz   � )�end)r%�ranger&�print�repr)r�level�str�args�i�argrrr�msgUs

zModuleFinder.msgcGs,|d}||jkr(|jd|_|j|�dS)Nr�)r%r&r4)rr1r/rrr�msgin^s
zModuleFinder.msgincGs,|d}||jkr(|jd|_|j|�dS)Nrr5)r%r&r4)rr1r/rrr�msgoutds
zModuleFinder.msgoutcCsB|jdd|�t|��"}ddtjf}|jd|||�WdQRXdS)N��
run_script��r�__main__)r4�open�imp�	PY_SOURCE�load_module)r�pathname�fp�stuffrrrr9js
zModuleFinder.run_scriptcCsTtjj|�\}}tjj|�\}}t|��"}|dtjf}|j||||�WdQRXdS)Nr;)�osr
�split�splitextr=r>r?r@)rrA�dirrZextrBrCrrr�	load_fileps

zModuleFinder.load_filer5c	Cs\|jdd||||�|j||d�}|j||�\}}|j||�}|sF|S|jrX|j||�dS)N��import_hook)r/)r4�determine_parent�find_head_package�	load_tailr�ensure_fromlist)	rr�caller�fromlistr/�parent�q�tail�mrrrrJwszModuleFinder.import_hookcCsP|jdd||�|s|dkr.|jdd�dS|j}|dkr�|jrJ|d8}|dkrz|j|}||ksht�|jdd|�|S|jd�|kr�td��dj|j	d�d|��}|j|}|jdd|�|S|jr�|j|}||ks�t�|jdd|�|Sd|k�r@|j
d�}|d|�}|j|}|j|k�s.t�|jdd|�|S|jdd�dS)	N�rKrzdetermine_parent -> Noner5zdetermine_parent ->�.zrelative importpath too deep)r6r7rrr#�AssertionError�count�ImportError�joinrE�rfind)rrOr/ZpnamerQr2rrrrK�sB





zModuleFinder.determine_parentcCs�|jdd||�d|kr@|jd�}|d|�}||dd�}n|}d}|r\d|j|f}n|}|j|||�}|r�|jdd||f�||fS|r�|}d}|j|||�}|r�|jdd||f�||fS|jdd|�td	|��dS)
NrUrLrVr5r:z%s.%szfind_head_package ->z"raise ImportError: No module namedzNo module named )r6�findr�
import_moduler7rY)rrQrr2�headrSZqnamerRrrrrL�s.
zModuleFinder.find_head_packagecCs�|jdd||�|}xz|r�|jd�}|dkr4t|�}|d|�||dd�}}d|j|f}|j|||�}|s|jdd|�td|��qW|jdd	|�|S)
NrUrMrVrr5z%s.%sz"raise ImportError: No module namedzNo module named zload_tail ->)r6r\�lenrr]r7rY)rrRrSrTr2r^ZmnamerrrrM�s
zModuleFinder.load_tailcCs�|jdd|||�xl|D]d}|dkrF|s||j|�}|r||j||d�qt||�sd|j|f}|j|||�}|std|��qWdS)NrUrN�*r5z%s.%szNo module named )r4�find_all_submodulesrN�hasattrrr]rY)rrTrP�	recursive�sub�all�subnameZsubmodrrrrN�s


zModuleFinder.ensure_fromlistc
Cs�|js
dSi}g}|tjjdd�7}|tjjdd�7}|tjjdd�7}x�|jD]�}ytj|�}Wn$tk
r�|j	dd|�wVYnXx\|D]T}d}x6|D].}t
|�}	||	d�|kr�|d|	�}Pq�W|r�|dkr�|||<q�WqVW|j�S)Nr8zcan't list directoryr)r�	importlib�	machinery�EXTENSION_SUFFIXES�SOURCE_SUFFIXES�BYTECODE_SUFFIXESrD�listdir�OSErrorr4r_�keys)
rrTr#�suffixesrG�namesr�modZsuff�nrrrra�s.

z ModuleFinder.find_all_submodulescCs|jdd|||�y|j|}Wntk
r4YnX|jdd|�|S||jkrb|jdd�dS|r�|jdkr�|jdd�dSy|j||o�|j|�\}}}Wn"tk
r�|jddd�dSXz|j||||�}Wd|r�|j	�X|r�t
|||�|jdd|�|S)NrIr]zimport_module ->zimport_module -> None)r6r#�KeyErrorr7r$r�find_modulerYr@�close�setattr)rZpartname�fqnamerQrTrBrArCrrrr]�s6

zModuleFinder.import_modulecCs|\}}}|jdd||od|�|tjkrH|j||�}|jdd|�|S|tjkrht|j�d|d�}	nj|tjkr�yt	j
j|j��}
Wn:tk
r�}z|jddt
|�|��WYdd}~XnXtj|
�}	nd}	|j|�}||_|	�r
|jr�|j|	�}	|	|_|j|	|�|jdd|�|S)Nr8r@rBzload_module ->�
�execzraise ImportError: )r6r>Z
PKG_DIRECTORY�load_packager7r?�compile�readZPY_COMPILEDrg�_bootstrap_external�_validate_bytecode_headerrYr0�marshal�loads�
add_modulerr(�replace_paths_in_coder�	scan_code)rrwrBrA�	file_info�suffix�mode�typerT�coZmarshal_data�excrrrr@s2





zModuleFinder.load_modulecCs<||jkri|j|<|r*d|j||j<nd|j|d<dS)Nr5�-)r$r)rrrOrrr�_add_badmodule4s


zModuleFinder._add_badmodulecCs||jkr|j||�dSy|j|||d�Wn@tk
rn}z$|jddt|��|j||�WYdd}~Xn�X|�rx�|D]�}||jkr�|j||�q|y|j|||g|d�Wq|tk
r�}z0|jddt|��|d|}|j||�WYdd}~Xq|Xq|WdS)N)r/r8zImportError:rV)r$r�rJrYr4r0)rrrOrPr/r4rd�fullnamerrr�_safe_import_hook<s&


zModuleFinder._safe_import_hookccs�|j}|j}|j}dd�tj|�D�}x�t|�D]�\}\}}|tkrVd||ffVq0|tkr0|dkr0||dd||ddko�tknr0|||dd}	|||dd}
|	dkr�d|
||ffVq0d|	|
||ffVq0q0WdS)	NcSs"g|]\}}}|tkr||f�qSr)�EXTENDED_ARG)�.0�_�opr3rrr�
<listcomp>Xsz-ModuleFinder.scan_opcodes.<locals>.<listcomp>�storer8r5r�absolute_import�relative_import)	�co_code�co_names�	co_consts�disZ_unpack_opargs�	enumerate�	STORE_OPSrr)rr��coderp�constsZopargsr2r�Zopargr/rPrrr�scan_opcodesSs 0zModuleFinder.scan_opcodescCs�|j}|j}�xT||�D�]F\}}|dkr<|\}d|j|<q|dk�r|\}}d}	|dk	rtd|krfd}	dd�|D�}|j|||dd�|	�r`d}
|jr�|jj|jd	|�}
|
dkr�|jj|�}
|
dk	r�|jj|
j�|j	j|
j	�|
j
dkr�d|j	|<n
d|j	|<q|d
k�rX|\}}}|�r4|j||||d�n"|j||d�}|j|jd|dd�qt|��qWx,|j
D]"}
t|
t|���rl|j|
|��qlWdS)Nr�r5r�rr`cSsg|]}|dkr|�qS)r`r)r��frrrr�usz*ModuleFinder.scan_code.<locals>.<listcomp>)r/rVr�)r�r�rr�rr#�getr�updaterrrK�RuntimeErrorr��
isinstancer�r�)rr�rTr��scannerZwhatr1rrPZ	have_starZmmr/rQ�crrrr�hsH



zModuleFinder.scan_codecCs�|jdd||�tj|�}|r"|}|j|�}||_|g|_|jtj|g�|_|jd|j�\}}}z"|j||||�|j	dd|�|S|r�|j
�XdS)Nr8rzrzload_package ->)r6rr�r�rrrrtr@r7ru)rrwrArrTrBZbufrCrrrrz�s

zModuleFinder.load_packagecCs*||jkr|j|St|�|j|<}|S)N)r#r)rrwrTrrrr��s

zModuleFinder.add_modulecCsr|dk	r|jd|}n|}||jkr<|jdd|�t|��|dkrf|tjkr`ddddtjffS|j}tj	||�S)NrVrIzfind_module -> Excludedr:)
rr'r7rYr"�builtin_module_namesr>Z	C_BUILTINr
rt)rrr
rQr�rrrrt�s

zModuleFinder.find_modulecCs"t�tdd�tdd�t|jj��}xJ|D]B}|j|}|jrTtddd�ntddd�td	||jppd
�q2W|j�\}}|r�t�td�x2|D]*}t|j|j��}td|d
dj|��q�W|�rt�tddd�td�x2|D]*}t|j|j��}td|d
dj|��q�WdS)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�Name�File�----�Pr*)r+rTz%-25sr:zMissing modules:�?z
imported fromz, z7Submodules that appear to be missing, but could also bez#global names in the parent package:N)r�r�)r�r�)	r-�sortedr#rnrr�any_missing_mayber$rZ)rrn�keyrT�missing�mayberZmodsrrr�report�s0



zModuleFinder.reportcCs|j�\}}||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�)rr�r�rrr�any_missing�szModuleFinder.any_missingcCs�g}g}x�|jD]�}||jkr q|jd�}|dkr>|j|�q||dd�}|d|�}|jj|�}|dk	r�||j|kr�|j|�q�||jkr�q�|jr�|j|�q�|j|�q|j|�qW|j�|j�||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.
        rVrr5N)	r$r'r[r	r#r�rr�sort)rr�r�rr2rfZpkgnameZpkgrrrr��s0	



zModuleFinder.any_missing_maybecCstjj|j�}}x2|jD](\}}|j|�r||t|�d�}PqW|jr�||jkr�||krt|j	dd||f�n|j	dd|f�|jj
|�t|j�}x8t
t|��D](}t||t|��r�|j||�||<q�Wtj|j|j|j|j|j|jt|�|j|j||j|j|j|j|j �S)Nr8zco_filename %r changed to %rz co_filename %r remains unchanged)!rDr
�normpath�co_filenamer(�
startswithr_r%r)r7r	�listr�r,r�r�r��types�CodeType�co_argcount�co_kwonlyargcount�
co_nlocals�co_stacksize�co_flagsr��tupler��co_varnames�co_name�co_firstlineno�	co_lnotab�co_freevars�co_cellvars)rr�Znew_filenameZoriginal_filenamer�r;r�r2rrrr�s,



z"ModuleFinder.replace_paths_in_code���)NNr�r�)r�)rr�)r�)N)rrr rr4r6r7r9rHrJrKrLrMrNrar]r@r�r�r�r�rzr�rtr�r�r�r�rrrrr!Gs2	

#

1
".r!cCs�ddl}y|jtjdd�d�\}}Wn*|jk
rP}zt|�dSd}~XnXd}d}g}g}xb|D]Z\}}	|dkr�|d}|dkr�d}|dkr�||	jtj�}|dkr�d}|dkrh|j|	�qhW|s�d	}
n|d}
tj	dd�}tj	j
|
�|d<||}|dk�r.td
�x|D]}tdt|���qWt|||�}
xp|dd�D]`}|dk�r^d}�qH|�r�|dd�d
k�r�|
j
|dd�ddg�n
|
j
|�n
|
j|��qHW|
j|
�|
j�|
S)Nrr5zdmp:qx:z-dz-mz-pz-qz-xzhello.pyzpath:z   r8z.*r`���r�)�getoptr"�argv�errorr-rErD�pathsepr	r
�dirnamer.r!rJrHr9r�)r�Zoptsr1r4r%ZdomodsZaddpathZexclude�o�aZscriptr
�item�mfr3rrr�test:sX



r�r<z
[interrupted])!�__doc__r�Zimportlib._bootstrap_externalrg�importlib.machineryrrDr"r�Zstruct�warnings�catch_warnings�simplefilter�DeprecationWarningr>Zopmaprrrrr�r�rr
rrrr!r�rr��KeyboardInterruptr-rrrr�<module>sB




v;