%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/modulefinder.pyo


Mac@sldZddlmZddlZddlZddlZddlZddlZddlZddl	Z	e
ejdrdZndZej
dZej
dZej
d	Zej
d
ZeefZejZejZdZiZdZiZd
ZdfdYZdfdYZdZedkrhy
eZWnek
rddGHnXndS(s3Find modules used by a script, using introspection.i(t
generatorsNtnewlinestUtrt
LOAD_CONSTtIMPORT_NAMEt
STORE_NAMEtSTORE_GLOBALccsd}t|}d}x||krt||}|}|d}d}|tkrt||t||dd|}d}|d}|tkr|d}qn|||fVqWdS(Niiiii(tlentordtNonet
HAVE_ARGUMENTtEXTENDED_ARG(tcodetextended_argtntitoptoffsettarg((s(/usr/local/lib/python2.7/modulefinder.pyt_unpack_opargss
*
cCs-tj|g}|j||t|<dS(N(tpackagePathMaptgettappend(tpackagenametpathtpaths((s(/usr/local/lib/python2.7/modulefinder.pytAddPackagePath6s
cCs|t|<dS(N(treplacePackageMap(toldnametnewname((s(/usr/local/lib/python2.7/modulefinder.pytReplacePackageBstModulecBs eZdddZdZRS(cCs:||_||_||_d|_i|_i|_dS(N(t__name__t__file__t__path__R
t__code__tglobalnameststarimports(tselftnametfileR((s(/usr/local/lib/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((s(/usr/local/lib/python2.7/modulefinder.pyt__repr__Us
N(R!t
__module__R
R*R-(((s(/usr/local/lib/python2.7/modulefinder.pyR Fs
tModuleFindercBseZddggdZdZdZdZdZdZddddZ	dd	Z
d
ZdZddZ
d
ZdZdZdZddZejdZdZdZdZdZddZdZdZdZdZRS(icCsd|dkrtj}n||_i|_i|_||_d|_||_||_g|_	dS(Ni(
R
tsysRtmodulest
badmodulestdebugtindenttexcludest
replace_pathstprocessed_paths(R'RR3R5R6((s(/usr/local/lib/python2.7/modulefinder.pyR*`s							cGsT||jkrPxt|jD]
}dGqW|Gx|D]}t|Gq8WHndS(Ns   (R3trangeR4trepr(R'tleveltstrtargsRR((s(/usr/local/lib/python2.7/modulefinder.pytmsgls
cGs=|d}||jkr9|jd|_|j|ndS(Nii(R3R4R=(R'R<R:((s(/usr/local/lib/python2.7/modulefinder.pytmsginus
cGs=|d}||jkr9|jd|_|j|ndS(Nii(R3R4R=(R'R<R:((s(/usr/local/lib/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((s(/usr/local/lib/python2.7/modulefinder.pyR@sc	Csttjj|\}}tjj|\}}t|t/}|dtjf}|j||||WdQXdS(NR(	tosRtsplittsplitextRCRDRERFRG(R'RHtdirR(textRIRJ((s(/usr/local/lib/python2.7/modulefinder.pyt	load_files
ic	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((s(/usr/local/lib/python2.7/modulefinder.pyRQs	cCs|jdd|||s)|dkr=|jdddS|j}|dkr|jrh|d8}n|dkr|j|}|jdd||S|jd|krtdndj|j	d| }|j|}|jdd||S|jr'|j|}|jdd||Sd|krp|j
d}|| }|j|}|jdd||S|jdddS(	NiRRisdetermine_parent -> Noneisdetermine_parent ->t.srelative importpath too deep(R>R?R
R!R#R1tcounttImportErrortjoinRLtrfind(R'RVR:tpnameRXR((s(/usr/local/lib/python2.7/modulefinder.pyRRs<		


	


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((s(/usr/local/lib/python2.7/modulefinder.pyRSs.


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>RbRR!RcR?R^(R'RYRZR[RRdtmname((s(/usr/local/lib/python2.7/modulefinder.pyRTs	cCs|jdd|||x|D]}|dkri|s|j|}|rf|j||dqfqq t||s d|j|f}|j|||}|std|qq q WdS(NiRUt*is%s.%ssNo module named (R=tfind_all_submodulesRUthasattrR!RcR^(R'R[RWt	recursivetsubtalltsubnametsubmod((s(/usr/local/lib/python2.7/modulefinder.pyRUs
cCs|js
dSi}g}x%tjD]}|j|dq&Wx|jD]}ytj|}Wn*tjk
r|jdd|qKnXxp|D]h}d}x:|D]2}	t	|	}
||
|	kr||
 }PqqW|r|dkr|||<qqWqKW|j
S(Niiscan't list directoryR*(R#REtget_suffixesRRKtlistdirterrorR=R
Rtkeys(R'R[R1tsuffixesttripleRNtnamesR(tmodtsuffR((s(/usr/local/lib/python2.7/modulefinder.pyRhs,	

cCsW|jdd|||y|j|}Wntk
r=nX|jdd||S||jkrx|jdddS|r|jdkr|jdddSy+|j||o|j|\}}}Wn%tk
r|jddddSXz|j	||||}Wd|r&|j
nX|r@t|||n|jdd||S(NiRcsimport_module ->simport_module -> None(R>R1tKeyErrorR?R2R
R#tfind_moduleR^RGtclosetsetattr(R'tpartnametfqnameRXR[RIRHRJ((s(/usr/local/lib/python2.7/modulefinder.pyRcs6
	"
c
Csr|\}}}|jdd||o'd||tjkrf|j||}|jdd||S|tjkrt|jd|d}	nr|tjkr|jdtj	kr|jdd|t
d	|n|jdtj|}	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((s(/usr/local/lib/python2.7/modulefinder.pyRG-s0
			cCsQ||jkri|j|<n|r<d|j||j<nd|j|d<dS(Nit-(R2R!(R'R(RV((s(/usr/local/lib/python2.7/modulefinder.pyt_add_badmoduleHs
cCs,||jkr#|j||dSy|j||d|Wn<tk
r{}|jddt||j||nX|r(x|D]}||jkr|j||qny |j|||gd|Wqtk
r }|jddt||d|}|j||qXqWndS(NR:isImportError:R\(R2RRQR^R=R;(R'R(RVRWR:R=Rktfullname((s(/usr/local/lib/python2.7/modulefinder.pyt_safe_import_hookPs&
 c
cs|j}|j}|j}gt|D]'\}}}|tkr(||f^q(}	xt|	D]\}
\}}ttkrd||ffVqbn|tkrb|
dkrb|	|
ddt	krb||	|
dd}d|||ffVqbqbqbWdS(Ntstoreiitimport(
tco_codetco_namest	co_constsRRt	enumeratetct	STORE_OPSRR(
R'RtunpackR
Rutconstst_RRtopargsRtopargRW((s(/usr/local/lib/python2.7/modulefinder.pytscan_opcodesgs			c
cs~|j}|j}|j}gt|D]'\}}}|tkr(||f^q(}x"t|D]\}	\}}
|tkrd||
ffVqbn|tkrb|	dkrb||	dd||	ddkotknrb|||	dd}|||	dd}|dkr4d|||
ffVqb|dkrXd|||
ffVqbd||||
ffVqbqbqbWdS(	NRiiiiRtabsolute_importtrelative_import(	RRRRRRRRR(
R'RR
RuRRRRRRRR:RW((s(/usr/local/lib/python2.7/modulefinder.pytscan_opcodes_25zs&			4cCs|j}tjd
kr$|j}n	|j}x||D]\}}|dkrk|\}d|j|<q:|dkr|\}}d}	|dk	rd|krd}	ng|D]}
|
dkr|
^q}n|dkrd}nd	}|j|||d
||	r@d}|jr;|j	j
|jd|}n|dkr\|j	j
|}n|dk	r|jj|j|j
j|j
|jdkrd|j
|<qqd|j
|<q@q:|dkr4|\}}}|r|j|||d
|q@|j|d
|}
|j|
jd|d
dq:t|q:Wx9|jD].}t|t|rN|j||qNqNWdS(NiiRiRRiRgiR:R\R(ii(RR(RR0tversion_infoRRR%R
RR#R1RR!tupdateR&R$RRtRuntimeErrorRt
isinstanceRR(R'RR[R
tscannertwhatR<R(RWt	have_startfR:tmmRXR((s(/usr/local/lib/python2.7/modulefinder.pyRsR				(		 cCs|jdd||tj|}|r4|}n|j|}||_|g|_|jtj|g|_|jd|j\}}}|j|||||j	dd||r|j
n|S(NiRR*sload_package ->(R>RRRR"R#RRyRGR?Rz(R'R}RHRR[RItbufRJ((s(/usr/local/lib/python2.7/modulefinder.pyRs		
cCs5||jkr|j|St||j|<}|S(N(R1R (R'R}R[((s(/usr/local/lib/python2.7/modulefinder.pyRscCs|dk	r |jd|}n|}||jkrT|jdd|t|n|dkr|tjkrddddtjffS|j	}ntj
||S(NR\isfind_module -> ExcludedRA(R
R!R5R?R^R0tbuiltin_module_namesREt	C_BUILTINRRy(R'R(RRXR((s(/usr/local/lib/python2.7/modulefinder.pyRyscCs<HddGHddGH|jj}|jxE|D]=}|j|}|jrVdGndGd|G|jpndGHq3W|j\}}|rHd	GHxH|D]=}|j|j}|jd
G|GdGdj|GHqWn|r8Hd
GdGHxH|D]=}|j|j}|jd
G|GdGdj|GHqWndS(sPrint 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(RR(s----s----(R1RrtsortR#R"tany_missing_maybeR2R_(R'RrtkeyR[tmissingtmaybeR(tmods((s(/usr/local/lib/python2.7/modulefinder.pytreports6		


	

!

cCs|j\}}||S(sReturn 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'RR((s(/usr/local/lib/python2.7/modulefinder.pytany_missingscCs"g}g}x|jD]}||jkr1qn|jd}|dkr_|j|qn||d}|| }|jj|}|dk	r||j|kr|j|q||jkrq|jr|j|q|j|q|j|qW|j	|j	||fS(sReturn 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(
R2R5R`RR1RR
R%R&R(R'RRR(RRmtpkgnametpkg((s(/usr/local/lib/python2.7/modulefinder.pyRs0	

	

cCstjj|j}}x>|jD]3\}}|j|r#||t|}Pq#q#W|jr||jkr||kr|j	dd||fn|j	dd|f|jj
|nt|j}xMt
t|D]9}t||t|r|j||||<qqWtj|j|j|j|j|jt||j|j||j|j|j|j|jS(Nisco_filename %r changed to %rs co_filename %r remains unchanged( RKRtnormpathtco_filenameR6t
startswithRR3R7R?RtlistRR8RRRttypestCodeTypetco_argcountt
co_nlocalstco_stacksizetco_flagsRttupleRtco_varnamestco_nametco_firstlinenot	co_lnotabtco_freevarstco_cellvars(R'Rtnew_filenametoriginal_filenameRRRR((s(/usr/local/lib/python2.7/modulefinder.pyRLs*N(R!R.R
R*R=R>R?R@RPRQRRRSRTRURhRcRGRRtstructRRRRRRRyRRRR(((s(/usr/local/lib/python2.7/modulefinder.pyR/^s4						#								6			%		.cCs"ddl}y#|jtjdd\}}Wn|jk
rM}|GHdSXd}d}g}g}x|D]\}}	|dkr|d}n|dkrd}n|dkr||	jtj}n|dkrd}n|d	krm|j|	qmqmW|sd
}
n
|d}
tj}tjj	|
|d<||}|dkrxdGHx |D]}dGt
|GHq\Wnt|||}
xz|dD]n}|dkrd}qn|r|d
dkr|
j|d
 ddgq|
j|q|
j|qW|
j|
|
j|
S(Niisdmp:qx:is-ds-ms-ps-qs-xshello.pyspath:s   is.*Rg(tgetoptR0targvRqRLRKtpathsepRRtdirnameR9R/RQR
RPR@R(RtoptsR<R=R3tdomodstaddpathtexcludetotatscriptRtitemtmfR((s(/usr/local/lib/python2.7/modulefinder.pyttesthsX#
			





RBs
[interrupt]( t__doc__t
__future__RtdisRERRKR0RRRit
__stdout__RDtopmapRRRRRRRRRRRRR R/RR!RtKeyboardInterrupt(((s(/usr/local/lib/python2.7/modulefinder.pyt<module>sB	



						;



Zerion Mini Shell 1.0