AlkantarClanX12

Your IP : 3.144.40.216


Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/modulefinder.cpython-35.opt-2.pyc



���]-Z�@swddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	e	j
��!e	jde�ddl
Z
WdQRXejdZejdZejdZejdZeefZejZiZdd�ZiZd	d
�ZGdd�d�ZGd
d�d�Zdd�Zedkrsy
e�ZWnek
rred�YnXdS)�N�ignore�
LOAD_CONST�IMPORT_NAME�
STORE_NAME�STORE_GLOBALcCstj|g�j|�dS)N)�packagePathMap�
setdefault�append)Zpackagename�path�r�1/opt/alt/python35/lib64/python3.5/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__1s					zModule.__init__cCsdd|jf}|jdk	r3|d|jf}|jdk	rV|d|jf}|d}|S)Nz	Module(%rz, %r�))rrr)r�srrr�__repr__>s
zModule.__repr__)r�
__module__�__qualname__rrrrrrr/s
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�ModuleFinderNrcCsa|dkrtj}||_i|_i|_||_d|_||_||_g|_dS)Nr)	�sysr
�modules�
badmodules�debug�indent�excludes�
replace_paths�processed_paths)rr
r%r'r(rrrrIs								zModuleFinder.__init__cGs{||jkrwx't|j�D]}tddd�qWt|dd�x$|D]}tt|�dd�qPWt�dS)Nz   �end� )r%�ranger&�print�repr)r�level�str�args�i�argrrr�msgUs
zModuleFinder.msgcGs:|d}||jkr6|jd|_|j|�dS)Nr�)r%r&r4)rr1r/rrr�msgin^s
zModuleFinder.msgincGs:|d}||jkr6|jd|_|j|�dS)Nrr5)r%r&r4)rr1r/rrr�msgoutds
zModuleFinder.msgoutcCsU|jdd|�t|��/}ddtjf}|jd|||�WdQRXdS)N��
run_script��r�__main__)r4�open�imp�	PY_SOURCE�load_module)r�pathname�fp�stuffrrrr9jszModuleFinder.run_scriptcCsrtjj|�\}}tjj|�\}}t|��/}|dtjf}|j||||�WdQRXdS)Nr;)�osr
�split�splitextr=r>r?r@)rrA�dirr�extrBrCrrr�	load_fileps
zModuleFinder.load_filer5c	Cs�|jdd||||�|j|d|�}|j||�\}}|j||�}|se|S|jr~|j||�dS)N��import_hookr/)r4�determine_parent�find_head_package�	load_tailr�ensure_fromlist)	rr�caller�fromlistr/�parent�q�tail�mrrrrKws	zModuleFinder.import_hookcCs�|jdd||�|s)|dkr=|jdd�dS|j}|dkr�|jre|d8}|dkr�|j|}|jdd|�|S|jd�|kr�td��dj|jd�d|��}|j|}|jdd|�|S|jr*|j|}|jdd|�|Sd|kry|j	d�}|d|�}|j|}|jdd|�|S|jdd�dS)	N�rLrzdetermine_parent -> Noner5zdetermine_parent ->�.zrelative importpath too deep)
r6r7rrr#�count�ImportError�joinrE�rfind)rrPr/ZpnamerRr2rrrrL�s<		

#
	

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�||fS|jdd|�td	|��dS)
NrVrMrWr5r:z%s.%szfind_head_package ->z"raise ImportError: No module namedzNo module named )r6�findr�
import_moduler7rY)rrRrr2�headrTZqnamerSrrrrM�s.

zModuleFinder.find_head_packagecCs�|jdd||�|}x�|r�|jd�}|dkrLt|�}|d|�||dd�}}d|j|f}|j|||�}|s|jdd|�td|��qW|jdd	|�|S)
NrVrNrWrr5z%s.%sz"raise ImportError: No module namedzNo module named zload_tail ->)r6r\�lenrr]r7rY)rrSrTrUr2r^ZmnamerrrrN�s	%zModuleFinder.load_tailcCs�|jdd|||�x�|D]�}|dkrc|s�|j|�}|r�|j||d�q t||�s d|j|f}|j|||�}|s td|��q WdS)NrVrO�*r5z%s.%szNo module named )r4�find_all_submodulesrO�hasattrrr]rY)rrUrQZ	recursive�sub�all�subnameZsubmodrrrrO�s
zModuleFinder.ensure_fromlistc
Cs<|js
dSi}g}|tjjdd�7}|tjjdd�7}|tjjdd�7}x�|jD]�}ytj|�}Wn(tk
r�|j	dd|�wqYnXxv|D]n}d}xC|D];}t
|�}	||	d�|kr�|d|	�}Pq�W|r�|dkr�|||<q�WqqW|j�S)Nr8zcan't list directoryr)r�	importlib�	machinery�EXTENSION_SUFFIXES�SOURCE_SUFFIXES�BYTECODE_SUFFIXESrD�listdir�OSErrorr4r_�keys)
rrUr#�suffixesrG�namesr�modZsuff�nrrrra�s.	


z ModuleFinder.find_all_submodulescCsV|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	�X|r?t
|||�|jdd|�|S)NrJr]zimport_module ->zimport_module -> None)r6r#�KeyErrorr7r$r�find_modulerYr@�close�setattr)rZpartname�fqnamerRrUrBrArCrrr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|�}||_|	rn|jrU|j|	�}	|	|_|j|	|�|jdd|�|S)Nr8r@rBzload_module ->�
�execzraise ImportError: )r6r>Z
PKG_DIRECTORY�load_packager7r?�compile�readZPY_COMPILEDrf�_bootstrap_external�_validate_bytecode_headerrYr0�marshal�loads�
add_modulerr(�replace_paths_in_coder�	scan_code)rrvrBrA�	file_info�suffix�mode�typerU�coZmarshal_data�excrrrr@s2			zModuleFinder.load_modulecCsN||jkri|j|<|r9d|j||j<nd|j|d<dS)Nr5�-)r$r)rrrPrrr�_add_badmodule4s

zModuleFinder._add_badmodulecCsJ||jkr#|j||�dSy|j||d|�WnNtk
r�}z.|jddt|��|j||�WYdd}~Xn�X|rFx�|D]�}||jkr�|j||�q�y |j|||gd|�Wq�tk
rA}z<|jddt|��|d|}|j||�WYdd}~Xq�Xq�WdS)Nr/r8zImportError:rW)r$r�rKrYr4r0)rrrPrQr/r4rc�fullnamerrr�_safe_import_hook<s&#
 zModuleFinder._safe_import_hookccs6|j}|j}|j}dd�tj|�D�}x�t|�D]�\}\}}	|tkrwd||	ffVqD|tkrD|dkrD||dd||ddko�tknrD|||dd}
|||dd}|
dkrd|||	ffVqDd|
|||	ffVqDqDWdS)	NcSs1g|]'\}}}|tkr||f�qSr)�EXTENDED_ARG)�.0�_�opr3rrr�
<listcomp>Ys	z0ModuleFinder.scan_opcodes_25.<locals>.<listcomp>�storer8r5r�absolute_import�relative_import)	�co_code�co_names�	co_consts�disZ_unpack_opargs�	enumerate�	STORE_OPSrr)rr��unpack�codero�constsZopargsr2r�Zopargr/rQrrr�scan_opcodes_25Ss 			4zModuleFinder.scan_opcodes_25cCs'|j}|j}x�||�D]�\}}|dkrP|\}d|j|<q|dkri|\}}d}	|dk	r�d|kr�d}	dd�|D�}|j|||dd�|	r�d}
|jr�|jj|jd	|�}
|
dkr|jj|�}
|
dk	rY|jj|
j�|j	j|
j	�|
j
dkrfd|j	|<q�d|j	|<q|d
kr�|\}}}|r�|j|||d|�q�|j|d|�}|j|jd|dd�qt|��qWx6|j
D]+}
t|
t|��r�|j|
|�q�WdS)Nr�r5r�rr`cSs"g|]}|dkr|�qS)r`r)r��frrrr�vs	z*ModuleFinder.scan_code.<locals>.<listcomp>r/rWr�)r�r�rr�rr#�getr�updaterrrL�RuntimeErrorr��
isinstancer�r�)rr�rUr��scannerZwhatr1rrQZ	have_starZmmr/rR�crrrr�isH				zModuleFinder.scan_codecCs�|jdd||�tj|�}|r1|}|j|�}||_|g|_|jtj|g�|_|jd|j�\}}}z1|j||||�|j	dd|�|SWd|r�|j
�XdS)Nr8ryrzload_package ->)r6rr�r�rrrrsr@r7rt)rrvrArrUrB�bufrCrrrry�s	zModuleFinder.load_packagecCs5||jkr|j|St|�|j|<}|S)N)r#r)rrvrUrrrr��szModuleFinder.add_modulecCs�|dk	r |jd|}n|}||jkrT|jdd|�t|��|dkr�|tjkr�ddddtjffS|j}tj	||�S)NrWrJzfind_module -> Excludedr:)
rr'r7rYr"�builtin_module_namesr>Z	C_BUILTINr
rs)rrr
rRr�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�xC|D];}t|j|j��}td|d
dj|��q�W|rxt�tddd�td�xC|D];}t|j|j��}td|d
dj|��q9WdS)Nz
  %-25s %s�Name�File�----�Pr*r+rUz%-25sr:zMissing modules:�?z
imported fromz, z7Submodules that appear to be missing, but could also bez#global names in the parent package:)r�r�)r�r�)	r-�sortedr#rmrr�any_missing_mayber$rZ)rrm�keyrU�missing�mayberZmodsrrr�report�s0

	

 

zModuleFinder.reportcCs|j�\}}||S)N)r�)rr�r�rrr�any_missing�szModuleFinder.any_missingcCs(g}g}x�|jD]�}||jkr.q|jd�}|dkrY|j|�q||dd�}|d|�}|jj|�}|dk	r�||j|kr�|j|�q||jkr�q|jr�|j|�q|j|�q|j|�qW|j�|j�||fS)NrWrr5)	r$r'r[r	r#r�rr�sort)rr�r�rr2reZpkgnameZpkgrrrr��s0	
	

zModuleFinder.any_missing_maybecCs�tjj|j�}}xA|jD]6\}}|j|�r#||t|�d�}Pq#W|jr�||jkr�||kr�|j	dd||f�n|j	dd|f�|jj
|�t|j�}xJt
t|��D]6}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���r�r�)rrr rr4r6r7r9rIrKrLrMrNrOrar]r@r�r��structr�r�r�ryr�rsr�r�r�r�rrrrr!Gs2	#1".r!cCsQddl}y)|jtjdd�d�\}}Wn6|jk
rm}zt|�dSWYdd}~XnXd}d}g}g}x�|D]�\}}	|dkr�|d}|dkr�d}|dkr�||	jtj�}|dkr�d}|dkr�|j|	�q�W|s!d	}
n
|d}
tj	dd�}tj	j
|
�|d<||}|dkr�td
�x!|D]}tdt|��q{Wt|||�}
x�|dd�D]w}|dkr�d}q�|r%|dd�d
kr|
j
|dd�ddg�q2|
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!rKrIr9r�)r�Zoptsr1r4r%ZdomodsZaddpathZexclude�o�aZscriptr
�item�mfr3rrr�test;sX)

	



#

r�r<z
[interrupted]) r�Zimportlib._bootstrap_externalrfZimportlib.machineryr~rDr"r�r��warnings�catch_warnings�simplefilter�PendingDeprecationWarningr>Zopmaprrrrr�r�rr
rrrr!r�rr��KeyboardInterruptr-rrrr�<module>s<




	��;