AlkantarClanX12

Your IP : 3.140.185.194


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/modulefinder.cpython-34.pyc

�
e f}[�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
e
j��!e
jde
�ddlZWdQXeejjd�g�Zeejjd�g�Zeejjd�g�Zeejjd�g�ZeegZeejg�ZiZdd	�ZiZd
d�ZGdd
�d
�ZGdd�d�Zdd�Zedkr�y
e�Z Wne!k
r�e"d�YnXndS)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�1/opt/alt/python34/lib64/python3.4/modulefinder.py�AddPackagePath!sr
cCs|t|<dS)N)�replacePackageMap)Zoldname�newnamerrr�ReplacePackage,src@s.eZdZdddd�Zdd�ZdS)�ModuleNcCs:||_||_||_d|_i|_i|_dS)N)�__name__�__file__�__path__�__code__�globalnames�starimports)�self�name�filer
rrr�__init__2s					zModule.__init__cCsjd|jf}|jdk	r6|d|jf}n|jdk	r\|d|jf}n|d}|S)Nz	Module(%rz, %r�))rrr)r�srrr�__repr__?s
zModule.__repr__)r�
__module__�__qualname__rrrrrrr0s
rc@sceZdZddggdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zddd6dd�Z	d7dd�Z
dd�Zdd�Zddd�Z
dd�Zdd�Zdd�Zd d!�Zd8d"d#�Zejd$d%�Zd&d'�Zd(d)�Zd*d+�Zdd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�ZdS)9�ModuleFinderNrcCsd|dkrtj}n||_i|_i|_||_d|_||_||_g|_dS)Nr)	�sysr
�modules�
badmodules�debug�indent�excludes�
replace_paths�processed_paths)rr
r%r'r(rrrrJs							zModuleFinder.__init__cGs~||jkrzx't|j�D]}tddd�qWt|dd�x$|D]}tt|�dd�qPWt�ndS)Nz   �end� )r%�ranger&�print�repr)r�level�str�args�i�argrrr�msgVs
zModuleFinder.msgcGs=|d}||jkr9|jd|_|j|�ndS)Nr�)r%r&r4)rr1r/rrr�msgin_s
zModuleFinder.msgincGs=|d}||jkr9|jd|_|j|�ndS)Nrr5)r%r&r4)rr1r/rrr�msgoutes
zModuleFinder.msgoutcCsT|jdd|�t|��/}ddtjf}|jd|||�WdQXdS)N��
run_script��r�__main__)r4�open�imp�	PY_SOURCE�load_module)r�pathname�fp�stuffrrrr9kszModuleFinder.run_scriptcCsqtjj|�\}}tjj|�\}}t|��/}|dtjf}|j||||�WdQXdS)Nr;)�osr
�split�splitextr=r>r?r@)rrA�dirrZextrBrCrrr�	load_fileqs
zModuleFinder.load_filer5c	Cs�|jdd||||�|j|d|�}|j||�\}}|j||�}|se|S|jr�|j||�ndS)N��import_hookr/)r4�determine_parent�find_head_package�	load_tailr�ensure_fromlist)	rr�caller�fromlistr/�parent�q�tail�mrrrrJxs	zModuleFinder.import_hookcCs�|jdd||�|s)|dkr=|jdd�dS|j}|dkr|jrh|d8}n|dkr�|j|}||ks�t�|jdd|�|S|jd�|kr�td��ndj|j	d�d|��}|j|}|jdd|�|S|jrT|j|}||ks=t�|jdd|�|Sd|kr�|j
d�}|d|�}|j|}|j|ks�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|krX|jd�}|d|�}||dd�}n|}d}|r�d|j|f}n|}|j|||�}|r�|jdd||f�||fS|r|}d}|j|||�}|r|jdd||f�||fSn|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||�|}x�|r�|jd�}|dkrOt|�}n|d|�||dd�}}d|j|f}|j|||�}|s|jdd|�td|��qqW|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|||�x�|D]�}|dkri|s�|j|�}|rf|j||d�qfq�q t||�s d|j|f}|j|||�}|s�td|��q�q q WdS)NrUrN�*r5z%s.%szNo module named )r4�find_all_submodulesrN�hasattrrr]rY)rrTrPZ	recursive�sub�all�subnameZsubmodrrrrN�s
zModuleFinder.ensure_fromlistc
CsB|js
dSi}g}|tjjdd�7}|tjjdd�7}|tjjdd�7}x�|jD]�}ytj|�}Wn(tk
r�|j	dd|�wqYnXx||D]t}d}xF|D]>}t
|�}	||	d�|kr�|d|	�}Pq�q�W|r�|dkr�|||<q�q�WqqW|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
r>YnX|jdd|�|S||jkry|jdd�dS|r�|jdkr�|jdd�dSy+|j||o�|j|�\}}}Wn)tk
r�|jddd�dSYnXz|j||||�}Wd|r+|j	�nX|rEt
|||�n|jdd|�|S)NrIr]zimport_module ->zimport_module -> None)r6r#�KeyErrorr7r$r�find_modulerYr@�close�setattr)rZpartname�fqnamerQrTrBrArCrrrr]�s6
	"
	zModuleFinder.import_modulecCs�|\}}}|jdd||o'd|�|tjkrf|j||�}|jdd|�|S|tjkr�t|j�d|d�}	n�|tjkryt	j
j|j��}
WnEtk
r}z%|jddt
|�|��WYdd}~XnXtj|
�}	nd}	|j|�}||_|	rt|jrX|j|	�}	n|	|_|j|	|�n|jdd|�|S)Nr8r@rBzload_module ->�
�execzraise ImportError: )r6r>Z
PKG_DIRECTORY�load_packager7r?�compile�readZPY_COMPILEDrf�
_bootstrap�_validate_bytecode_headerrYr0�marshal�loads�
add_modulerr(�replace_paths_in_coder�	scan_code)rrvrBrA�	file_info�suffix�mode�typerT�coZmarshal_data�excrrrr@s2			zModuleFinder.load_modulecCsQ||jkri|j|<n|r<d|j||j<nd|j|d<dS)Nr5�-)r$r)rrrOrrr�_add_badmodule5s
zModuleFinder._add_badmodulecCsP||jkr#|j||�dSy|j||d|�WnNtk
r�}z.|jddt|��|j||�WYdd}~Xn�X|rLx�|D]�}||jkr�|j||�q�ny |j|||gd|�Wq�tk
rD}z<|jddt|��|d|}|j||�WYdd}~Xq�Xq�WndS)Nr/r8zImportError:rV)r$r�rJrYr4r0)rrrOrPr/r4rc�fullnamerrr�_safe_import_hook=s&#
 zModuleFinder._safe_import_hookc
csk|j}|j}|j}ttt}x;|rft|dg�}|tkr�|d|dd��\}d||ffV|dd�}q,n|ddd�|kr4|d|dd��\}	}
}||	}|dkrd||
||ffVnd	|||
||ffV|dd�}q,n|tkrS|dd�}q,|dd�}q,WdS)
Nrz<Hr5rI�store�	z<xHxHxH�absolute_import�relative_import)�co_code�co_names�	co_constsrr�bytes�	STORE_OPS�
HAVE_ARGUMENT)
rr��unpack�codero�constsZLOAD_LOAD_AND_IMPORT�cZopargZoparg_1Zoparg_2Zoparg_3r/rrr�scan_opcodes_25Ts,				"
zModuleFinder.scan_opcodes_25cCs<|j}|j}x�||�D]�\}}|dkrP|\}d|j|<q|dkr{|\}}d}	|dk	r�d|kr�d}	ndd�|D�}n|j|||dd�|	r�d}
|jr�|jj|jd	|�}
n|
dkr|jj|�}
n|
dk	rh|jj|
j�|j	j|
j	�|
j
dkrud|j	|<quqxd|j	|<q�q|d
kr�|\}}}|r�|j|||d|�q�|j|d|�}|j|jd|dd�qt|��qWx9|j
D].}
t|
t|��r|j|
|�qqWdS)Nr�r5r�rr`cSs"g|]}|dkr|�qS)r`r)�.0�frrr�
<listcomp>~s	z*ModuleFinder.scan_code.<locals>.<listcomp>r/rVr�)r�r�rr�rr#�getr�updaterrrK�RuntimeErrorr��
isinstancer�r�)rr�rTr��scannerZwhatr1rrPZ	have_starZmmr/rQr�rrrr�qsH					 zModuleFinder.scan_codecCs�|jdd||�tj|�}|r4|}n|j|�}||_|g|_|jtj|g�|_|jd|j�\}}}z1|j||||�|j	dd|�|SWd|r�|j
�nXdS)Nr8ryrzload_package ->)r6rr�r�rrrrsr@r7rt)rrvrArrTrBZbufrCrrrry�s		zModuleFinder.load_packagecCs5||jkr|j|St|�|j|<}|S)N)r#r)rrvrTrrrr��szModuleFinder.add_modulecCs�|dk	r |jd|}n|}||jkrW|jdd|�t|��n|dkr�|tjkr�ddddtjffS|j}ntj	||�S)NrVrIzfind_module -> Excludedr:)
rr'r7rYr"�builtin_module_namesr>Z	C_BUILTINr
rs)rrr
rQr�rrrrs�szModuleFinder.find_modulecCs�t�tdd�tdd�t|jj��}xa|D]Y}|j|}|jrntddd�ntddd�td	||jp�d
�q?W|j�\}}|rt�td�xF|D];}t|j|j��}td|d
dj|��q�Wn|r~t�tddd�td�xF|D];}t|j|j��}td|d
dj|��q<WndS)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)zNamer�)r�r�)	r-�sortedr#rmrr�any_missing_mayber$rZ)rrm�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�szModuleFinder.any_missingcCs.g}g}x|jD]�}||jkr1qn|jd�}|dkr_|j|�qn||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�rr2reZpkgnameZpkgrrrr��s0	
	

zModuleFinder.any_missing_maybecCs�tjj|j�}}xD|jD]9\}}|j|�r#||t|�d�}Pq#q#W|jr�||jkr�||kr�|j	dd||f�n|j	dd|f�|jj
|�nt|j�}xMt
t|��D]9}t||t|��r�|j||�||<q�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���r�r�)rrr rr4r6r7r9rHrJrKrLrMrNrar]r@r�r��structr�r�r�ryr�rsr�r�r�r�rrrrr!Hs2	#1".r!cCsfddl}y)|jtjdd�d�\}}Wn6|jk
rm}zt|�dSWYdd}~XnXd}d}g}g}x�|D]�\}}	|dkr�|d}n|dkr�d}n|dkr�||	jtj�}n|dkrd}n|dkr�|j|	�q�q�W|s0d	}
n
|d}
tj	dd�}tj	j
|
�|d<||}|dkr�td
�x$|D]}tdt|��q�Wnt|||�}
x�|dd�D]z}|dkr�d}q�n|r:|dd�d
kr*|
j
|dd�ddg�qG|
j
|�q�|
j|�q�W|
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�testCsX)

			



#

r�r<z
[interrupted])#�__doc__ZdisZimportlib._bootstraprf�importlib.machineryr~rDr"r�r��warnings�catch_warnings�simplefilter�PendingDeprecationWarningr>r��opname�indexrrrrr�r�rr
rrrr!r�rr��KeyboardInterruptr-rrrr�<module>s>
��;