ó ®XRc@sÖdZedkr'ddljjZnddlZddlZddlZdZdZ de fd„ƒYZ edkr’de fd „ƒYZ nd ejfd „ƒYZedkrÒejd Zy»eejd deƒZejejdƒZxYegeD]'Zeejƒƒeejƒf^qƒD]Zejjdefƒq1Wejƒ\ZZejj d„eDƒƒWnMe!k r¨Z"ejjde"ƒn'e k rÎZ"ejjde"ƒnXndS(sA standalone version of ModuleFinder which limits the depth of exploration for loaded modules and discovers where a module might be loaded instead of determining which path contains a module to be loaded. It is designed to be run by any version of python against its set of modules. To communicate its results to the process which ran it, it prints output to stdout. The format is to start a line with 'DEP ' if it contains information about a dependency, and 'ERR ' if it contains information about a module it couldn't analyze.t__main__iÿÿÿÿNs$PKGDEPEND_RUNPATHt PYTHONPATHt ModuleInfocBs>eZdZed„Zd„Zd„Zd„Zd„ZRS(sYThis class contains information about from where a python module might be loaded.cCs@||_||_ddddddg|_t|ƒ|_dS(s>Build a ModuleInfo object. The 'name' parameter is the name of the module. The 'dirs' parameter is the list of directories where the module might be found. The 'builtin' parameter sets whether the module is a python builtin (like sys).s.pys.pycs.pyos /__init__.pys.sos module.soN(tnametbuiltintsuffixestsortedtdirs(tselfRRR((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyt__init__*s   cCs%|jrdg|_n g|_dS(s&Declare that this module is a package.s /__init__.pyN(RR(R((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyt make_package;s cCs,g|jD]}tjj||jƒ^q S(s8Get the directories where this package might be defined.(RtostpathtjoinR(Rtp((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pytget_package_dirsCscCs'g|jD]}d|j|f^q S(sQReturn all the file names under which this module might be found.s%s%s(RR(Rtsuf((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pytget_file_namesHscCs)d|jdj|jƒt|jƒfS(Nsname:%s suffixes:%s dirs:%st (RR RtlenR(R((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyt__str__Ns ( t__name__t __module__t__doc__tFalseR R RRR(((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyR&s     tMultipleDefaultRunPathscBseZd„Zd„ZRS(cCs t|ƒS(N(tstr(R((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyt __unicode__VscCs tdƒS(NsSMore than one $PKGDEPEND_RUNPATH token was set on the same action in this manifest.(t_(R((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyR]s(RRRR(((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyRTs tDepthLimitedModuleFindercBsweZd„Zed„ƒZd„Zd„Zd„Zdd„Zd d dd„Z d„Z d d „Z d „Z RS( c OsJ|jdgƒ}ttjkr\gtjtjtjƒD]}tjj|ƒ^q;}ng}gtjdD]}|j ||ƒsp|^qp}|j |ƒ|r*t dkrÈt j ||ƒ}q*yE|jtƒ}|| |||d}t|kr tƒ‚nWntk r nX|}ntjj|d|||ŽdS(sùProduce a module finder that ignores PYTHONPATH and only reports the direct imports of a module. run_paths as a keyword argument specifies a list of additional paths to use when searching for modules.t run_pathsiRR N(tpopt python_pathR tenvirontsplittpathsepR tnormpathtsyststartswith_pathtappendRtbasetinsert_default_runpathtindextPD_DEFAULT_RUNPATHRt ValueErrort modulefindert ModuleFinderR ( Rt install_dirtargstkwargsRtfptpy_pathtnew_pathR*((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyR es08        cCs(x!|D]}|j|ƒrtSqWtS(N(t startswithtTrueR(R tlsttl((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyR&šs cCs"t|dƒ}|jd||ƒS(sMFind all the modules the module at pathname directly imports.trR(topent load_module(RtpathnameR2((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyt run_script¡scCsÿ|jdd||od|ƒt|jƒd|dƒ}|j|ƒ}||_g}|rè|jrz|j|ƒ}n||_y|j|j ||ƒƒWqèt k rä}|j ddt |ƒ||ƒ|j ||ƒqèXn|jdd|ƒ|S(sôThis code has been slightly modified from the function of the parent class. Specifically, it checks the current depth of the loading and halts if it exceeds the depth that was given to run_script.iR;R2s texecs ImportError:sload_module ->(tmsgintcompiletreadt add_modulet__file__t replace_pathstreplace_paths_in_codet__code__textendt scan_codet ImportErrortmsgRt_add_badmoduletmsgout(RtfqnameR2R<tcotmtresRJ((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyR;¨s"   cCsôg}|j}tjd kr*|j}n |j}xu||ƒD]g\}}|dkrq|\}d|j|simport_module -> NoneN( R\R?tmodulestKeyErrorRLRkRRt find_moduleRI(RtpartnameRMRit parent_dirsROtmod((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyRw0s,   cCsM|s@|tjks!|dkr4t|gdtƒS|j}nt||ƒS(saCalculate the potential paths on the file system where the module could be found.RoR(R%RsRR6R (RRR Ri((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyRzLs  c Cs|jdd||ƒg}|j}|}x‹|r¸|jdƒ}|dkr^t|ƒ}n|| ||d}}d||f}|j|||ƒ} |j| ƒ|}| }q.Wx/tdt|ƒdƒD]}||jƒqÓW|jdd|ƒ|S(shDetermine where each component of a multilevel import would be found on the file system.iRtt.iis%s.%ss load_tail ->( R?RtfindRRwR'trangeR RL( RRuRvRPRt cur_parenttitheadtnew_nameR9((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyRtVs$      N(RRR t staticmethodR&R=R;RHR]R\RlRwRzRt(((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyRcs 5   0 (  iiRisDEP %s ccs|]}d|VqdS(sERR %s N((t.0R((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pys €ssERR %s s%s (#RRtpkg.flavor.basetflavorR(R-R R%R+R tobjectRt ExceptionRR.RtargvRtmfR=tloaded_modulestsetROttupleRRRPtstdouttwritetany_missing_maybetmissingtmaybet writelinesR,te(((s?/usr/lib/python2.7/vendor-packages/pkg/flavor/depthlimitedmf.pyts6    - ÿ  8