Your IP : 18.118.30.153


Current Path : /opt/alt/python27/lib64/python2.7/
Upload File :
Current File : //opt/alt/python27/lib64/python2.7/modulefinder.pyc

�
^
bc@sldZddlmZddlZddlZddlZddlZddlZddlZddl	Z	e
ejd�r�dZndZej
dZej
dZej
d	Zej
d
ZeefZejZejZd�ZiZd�ZiZd
�Zdfd��YZdfd��YZd�Zedkrhy
e�ZWnek
rddGHnXndS(s3Find modules used by a script, using introspection.i����(t
generatorsNtnewlinestUtrt
LOAD_CONSTtIMPORT_NAMEt
STORE_NAMEtSTORE_GLOBALccs�d}t|�}d}x�||kr�t||�}|}|d}d}|tkr�t||�t||d�d|}d}|d}|tkr�|d}q�n|||fVqWdS(Niiiii(tlentordtNonet
HAVE_ARGUMENTtEXTENDED_ARG(tcodetextended_argtntitoptoffsettarg((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyt_unpack_opargss
*
cCs-tj|g�}|j|�|t|<dS(N(tpackagePathMaptgettappend(tpackagenametpathtpaths((s1/opt/alt/python27/lib64/python2.7/modulefinder.pytAddPackagePath6s
cCs|t|<dS(N(treplacePackageMap(toldnametnewname((s1/opt/alt/python27/lib64/python2.7/modulefinder.pytReplacePackageBstModulecBs eZddd�Zd�ZRS(cCs:||_||_||_d|_i|_i|_dS(N(t__name__t__file__t__path__R
t__code__tglobalnameststarimports(tselftnametfileR((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyt__init__Hs					cCsjd|jf}|jdk	r6|d|jf}n|jdk	r\|d|jf}n|d}|S(Ns	Module(%rs, %rt)(R!R"R
R#(R'ts((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyt__repr__Us
N(R!t
__module__R
R*R-(((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyR Fs
tModuleFindercBseZddggd�Zd�Zd�Zd�Zd�Zd�Zdddd�Z	dd	�Z
d
�Zd�Zdd�Z
d
�Zd�Zd�Zd�Zdd�Zejd�Zd�Zd�Zd�Zd�Zdd�Zd�Zd�Zd�Zd�ZRS(icCsd|dkrtj}n||_i|_i|_||_d|_||_||_g|_	dS(Ni(
R
tsysRtmodulest
badmodulestdebugtindenttexcludest
replace_pathstprocessed_paths(R'RR3R5R6((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyR*`s							cGsT||jkrPxt|j�D]
}dGqW|Gx|D]}t|�Gq8WHndS(Ns   (R3trangeR4trepr(R'tleveltstrtargsRR((s1/opt/alt/python27/lib64/python2.7/modulefinder.pytmsgls
cGs=|d}||jkr9|jd|_|j|�ndS(Nii(R3R4R=(R'R<R:((s1/opt/alt/python27/lib64/python2.7/modulefinder.pytmsginus
cGs=|d}||jkr9|jd|_|j|�ndS(Nii(R3R4R=(R'R<R:((s1/opt/alt/python27/lib64/python2.7/modulefinder.pytmsgout{s
c	CsW|jdd|�t|t��/}ddtjf}|jd|||�WdQXdS(Nit
run_scripttRt__main__(R=topent	READ_MODEtimpt	PY_SOURCEtload_module(R'tpathnametfptstuff((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyR@�sc	Csttjj|�\}}tjj|�\}}t|t��/}|dtjf}|j||||�WdQXdS(NR(	tosRtsplittsplitextRCRDRERFRG(R'RHtdirR(textRIRJ((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyt	load_file�s
i����c	Cs�|jdd||||�|j|d|�}|j||�\}}|j||�}|se|S|jr�|j||�ndS(Nitimport_hookR:(R=tdetermine_parenttfind_head_packaget	load_tailR#tensure_fromlistR
(	R'R(tcallertfromlistR:tparenttqttailtm((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyRQ�s	cCs�|jdd||�|s)|dkr=|jdd�dS|j}|dkr|jrh|d8}n|dkr�|j|}||ks�t�|jdd|�|S|jd�|kr�td�ndj	|j
d�| �}|j|}|jdd|�|S|jrK|j|}||ks4t�|jdd|�|Sd|kr�|jd�}|| }|j|}|j|ks�t�|jdd|�|S|jdd�dS(	NiRRisdetermine_parent -> Noneisdetermine_parent ->t.srelative importpath too deep(R>R?R
R!R#R1tAssertionErrortcounttImportErrortjoinRLtrfind(R'RVR:tpnameRXR((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyRR�sB		


	


cCs/|jdd||�d|krL|jd�}|| }||d}n|}d}|rtd|j|f}n|}|j|||�}|r�|jdd||f�||fS|r|}d}|j|||�}|r|jdd||f�||fSn|jdd|�td	|�dS(
NiRSR\iRAs%s.%ssfind_head_package ->s"raise ImportError: No module namedsNo module named (R>tfindR!t
import_moduleR?R
R_(R'RXR(RtheadRZtqnameRY((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyRS�s.


cCs�|jdd||�|}x�|r�|jd�}|dkrOt|�}n|| ||d}}d|j|f}|j|||�}|s|jdd|�td|�qqW|jdd	|�|S(
NiRTR\iis%s.%ss"raise ImportError: No module namedsNo module named sload_tail ->(R>RcRR!RdR?R_(R'RYRZR[RRetmname((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyRT�s	cCs�|jdd|||�x�|D]�}|dkri|s�|j|�}|rf|j||d�qfq�q t||�s d|j|f}|j|||�}|s�td|�q�q q WdS(NiRUt*is%s.%ssNo module named (R=tfind_all_submodulesRUthasattrR!RdR_(R'R[RWt	recursivetsubtalltsubnametsubmod((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyRU�s
cCs|js
dSi}g}x%tj�D]}|j|d�q&Wx�|jD]�}ytj|�}Wn*tjk
r�|jdd|�qKnXxp|D]h}d}x:|D]2}	t	|	�}
||
|	kr�||
 }Pq�q�W|r�|dkr�|||<q�q�WqKW|j
�S(Niiscan't list directoryR*(R#REtget_suffixesRRKtlistdirterrorR=R
Rtkeys(R'R[R1tsuffixesttripleRNtnamesR(tmodtsuffR((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyRi�s,	

cCsW|jdd|||�y|j|}Wntk
r=nX|jdd|�|S||jkrx|jdd�dS|r�|jdkr�|jdd�dSy+|j||o�|j|�\}}}Wn%tk
r�|jddd�dSXz|j	||||�}Wd|r&|j
�nX|r@t|||�n|jdd|�|S(NiRdsimport_module ->simport_module -> None(R>R1tKeyErrorR?R2R
R#tfind_moduleR_RGtclosetsetattr(R'tpartnametfqnameRXR[RIRHRJ((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyRds6
	"
c
Csr|\}}}|jdd||o'd|�|tjkrf|j||�}|jdd|�|S|tjkr�t|j�d|d�}	nr|tjkr|jd�tj	�kr�|jdd|�t
d	|�n|jd�tj|�}	nd}	|j|�}||_|	r[|jr?|j|	�}	n|	|_|j|	|�n|jdd|�|S(
NiRGRIsload_module ->s
texecis#raise ImportError: Bad magic numbersBad magic number in %s(R>REt
PKG_DIRECTORYtload_packageR?RFtcompiletreadtPY_COMPILEDt	get_magicR_tmarshaltloadR
t
add_moduleR"R6treplace_paths_in_codeR$t	scan_code(
R'R~RIRHt	file_infotsuffixtmodettypeR[tco((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyRG-s0
			cCsQ||jkri|j|<n|r<d|j||j<nd|j|d<dS(Nit-(R2R!(R'R(RV((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyt_add_badmoduleHs
cCs,||jkr#|j||�dSy|j||d|�Wn<tk
r{}|jddt|��|j||�n�X|r(x�|D]�}||jkr�|j||�q�ny |j|||gd|�Wq�tk
r }|jddt|��|d|}|j||�q�Xq�WndS(NR:isImportError:R\(R2R�RQR_R=R;(R'R(RVRWR:R=Rltfullname((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyt_safe_import_hookPs&
 c
cs|j}|j}|j}gt|�D]'\}}}|tkr(||f^q(}	x�t|	�D]�\}
\}}ttkr�d||ffVqbn|tkrb|
dkrb|	|
ddt	krb||	|
dd}d|||ffVqbqbqbWdS(Ntstoreiitimport(
tco_codetco_namest	co_constsRRt	enumeratetct	STORE_OPSRR(
R'R�tunpackR
Rvtconstst_RRtopargsRtopargRW((s1/opt/alt/python27/lib64/python2.7/modulefinder.pytscan_opcodesgs			c
cs~|j}|j}|j}gt|�D]'\}}}|tkr(||f^q(}x"t|�D]\}	\}}
|tkr�d||
ffVqbn|tkrb|	dkrb||	dd||	ddko�tknrb|||	dd}|||	dd}|dkr4d|||
ffVqb|dkrXd|||
ffVqbd||||
ffVqbqbqbWdS(	NR�iiii����R�tabsolute_importtrelative_import(	R�R�R�RRR�R�RR(
R'R�R
RvR�R�RRR�RR�R:RW((s1/opt/alt/python27/lib64/python2.7/modulefinder.pytscan_opcodes_25zs&			4cCs�|j}tjd
kr$|j}n	|j}x||�D]\}}|dkrk|\}d|j|<q:|dkr�|\}}d}	|dk	r�d|kr�d}	ng|D]}
|
dkr�|
^q�}n|dkr�d}nd	}|j|||d
|�|	r@d}|jr;|j	j
|jd|�}n|dkr\|j	j
|�}n|dk	r�|jj|j�|j
j|j
�|jdkr�d|j
|<q�q�d|j
|<q@q:|dkr4|\}}}|r|j|||d
|�q@|j|d
|�}
|j|
jd|d
d�q:t|��q:Wx9|jD].}t|t|��rN|j||�qNqNWdS(NiiR�iR�R�iRhi����R:R\R�(ii(R�R�(R�R0tversion_infoR�R�R%R
R�R#R1RR!tupdateR&R$RRtRuntimeErrorR�t
isinstanceR�R�(R'R�R[R
tscannertwhatR<R(RWt	have_startfR:tmmRXR�((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyR��sR				(		 cCs�|jdd||�tj|�}|r4|}n|j|�}||_|g|_|jtj|g�|_|jd|j�\}}}|j||||�|j	dd|�|r�|j
�n|S(NiR�R*sload_package ->(R>RRR�R"R#RRzRGR?R{(R'R~RHRR[RItbufRJ((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyR��s		
cCs5||jkr|j|St|�|j|<}|S(N(R1R (R'R~R[((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyR��scCs�|dk	r |jd|}n|}||jkrT|jdd|�t|�n|dkr�|tjkr�ddddtjffS|j	}ntj
||�S(NR\isfind_module -> ExcludedRA(R
R!R5R?R_R0tbuiltin_module_namesREt	C_BUILTINRRz(R'R(RRXR�((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyRz�scCs<HddGHddGH|jj�}|j�xE|D]=}|j|}|jrVdGndGd|G|jpndGHq3W|j�\}}|r�Hd	GHxH|D]=}|j|j�}|j�d
G|GdGdj|�GHq�Wn|r8Hd
GdGHxH|D]=}|j|j�}|j�d
G|GdGdj|�GHq�WndS(s�Print a report to stdout, listing the found modules with their
        paths, as well as modules that are missing, or seem to be missing.
        s
  %-25s %stNametFiles----tPR[s%-25sRAsMissing modules:t?s
imported froms, s7Submodules that appear to be missing, but could also bes#global names in the parent package:N(R�R�(s----s----(R1RstsortR#R"tany_missing_maybeR2R`(R'RstkeyR[tmissingtmaybeR(tmods((s1/opt/alt/python27/lib64/python2.7/modulefinder.pytreport�s6		


	

!

cCs|j�\}}||S(s�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�(R'R�R�((s1/opt/alt/python27/lib64/python2.7/modulefinder.pytany_missingscCs"g}g}x�|jD]�}||jkr1qn|jd�}|dkr_|j|�qn||d}|| }|jj|�}|dk	r�||j|kr�|j|�q||jkr�q|jr�|j|�q|j|�q|j|�qW|j	�|j	�||fS(s�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\iiN(
R2R5RaRR1RR
R%R&R�(R'R�R�R(RRntpkgnametpkg((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyR�s0	

	

cCs�tjj|j�}}x>|jD]3\}}|j|�r#||t|�}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|jt|�|j|j||j|j|j|j|j�S(Nisco_filename %r changed to %rs co_filename %r remains unchanged( RKRtnormpathtco_filenameR6t
startswithRR3R7R?RtlistR�R8R�R�R�ttypestCodeTypetco_argcountt
co_nlocalstco_stacksizetco_flagsR�ttupleR�tco_varnamestco_nametco_firstlinenot	co_lnotabtco_freevarstco_cellvars(R'R�tnew_filenametoriginal_filenameR�RR�R((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyR�Ls*N(R!R.R
R*R=R>R?R@RPRQRRRSRTRURiRdRGR�R�tstructR�R�R�R�R�R�RzR�R�R�R�(((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyR/^s4						#								6			%		.cCs"ddl}y#|jtjdd�\}}Wn|jk
rM}|GHdSXd}d}g}g}x�|D]�\}}	|dkr�|d}n|dkr�d}n|dkr�||	jtj�}n|dkr�d}n|d	krm|j|	�qmqmW|sd
}
n
|d}
tj}tjj	|
�|d<||}|dkrxdGHx |D]}dGt
|�GHq\Wnt|||�}
xz|dD]n}|dkr�d}q�n|r�|d
dkr�|
j|d
 ddg�q|
j|�q�|
j|�q�W|
j|
�|
j�|
S(Ni����isdmp:qx:is-ds-ms-ps-qs-xshello.pyspath:s   i����s.*Rh(tgetoptR0targvRrRLRKtpathsepRRtdirnameR9R/RQR
RPR@R�(R�toptsR<R=R3tdomodstaddpathtexcludetotatscriptRtitemtmfR((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyttesthsX#
			





RBs
[interrupt]( t__doc__t
__future__RtdisRER�RKR0R�R�Rjt
__stdout__RDtopmapRRRRR�RRRRRRRR R/R�R!R�tKeyboardInterrupt(((s1/opt/alt/python27/lib64/python2.7/modulefinder.pyt<module>sB	



					��	;



?>