ó K9•Qc@sÇdZddlZddlZddlZddlmZddlmZmZm Z m Z ej e ƒZ yejjZWnek r—d„ZnXdefd„ƒYZdd„Zd „ZdS( s:Implements an importer that looks only in specific path (ignoring sys.path), and uses a per-path cache in addition to sys.modules. This is necessary because test modules in different directories frequently have the same names, which means that the first loaded would mask the rest when using the builtin importer. iÿÿÿÿN(tConfig(t find_modulet load_modulet acquire_lockt release_lockcCs:tjjtjj|ƒƒtjjtjj|ƒƒkS(N(tostpathtnormcasetrealpath(tsrctdst((s1/sys/lib/python2.7/site-packages/nose/importer.pyt _samefilestImportercBs>eZdZdd„Zd„Zd„Zd„Zd„ZRS(s³An importer class that does only path-specific imports. That is, the given module is not searched for on sys.path, but only at the path or in the directory specified. cCs%|dkrtƒ}n||_dS(N(tNoneRtconfig(tselfR((s1/sys/lib/python2.7/site-packages/nose/importer.pyt__init__s  cCsŒtjjtjj|ƒƒjtjƒ}|jdƒ}|djdƒrY|jƒn|t|ƒ }tjj |ƒ}|j ||ƒS(sÌImport a dotted-name package whose tail is at path. In other words, given foo.bar and path/to/foo/bar.py, import foo from path/to/foo then bar from path/to/foo/bar, returning bar. t.iÿÿÿÿR( RRtnormpathtabspathtsplittsept startswithtpoptlentjoint importFromDir(RRtfqnamet path_partst name_partstdir_path((s1/sys/lib/python2.7/site-packages/nose/importer.pytimportFromPath"s* c Csÿtjjtjj|ƒƒ}tjd||ƒ|dkrHtj|S|jj rgt ||jƒn|g}|j dƒ}d}d }}}xe|D]]} |dkrµ| }nd|| f}zÚt ƒtjd| ||ƒt| |ƒ\}} } tjj|ƒ} | d k r‰tjd|| ƒ|j| | ƒs^|jjrgt| dd ƒrg| }qžtj|=t||| | ƒ}nt||| | ƒ}Wd |rµ|jƒntƒX|rÖt|| |ƒnt|dƒrñ|j}n|}qšW|S( sˆImport a module *only* from path, ignoring sys.path and reloading if the version in sys.modules is not the one we want. sImport %s from %st__main__Rts%s.%ssfind module part %s (%s) in %sssys.modules has %s as %st__path__N(RRRRtlogtdebugtsystmodulesRtaddPathstadd_pathRR RRtgett sameModuletfirstPackageWinstgetattrRtcloseRtsetattrthasattrR"( RtdirRRtpartst part_fqnametmodtparenttfhtparttfilenametdesctold((s1/sys/lib/python2.7/site-packages/nose/importer.pyR1sL                cCs*tjj|ƒr|Stjj|ƒSdS(N(RRtisdirtdirname(RR7((s1/sys/lib/python2.7/site-packages/nose/importer.pyt_dirname_if_filejscCs»g}t|dƒrBxY|jD]}|j|j|ƒƒqWn/t|dƒrm|j|j|jƒƒntS|j|ƒ}x4|D],}tjd||ƒt||ƒr‡t Sq‡WtS(NR"t__file__s&module already loaded? mod: %s new: %s( R/R"tappendR<R=tFalseR#R$R tTrue(RR3R7t mod_pathsRtnew_pathtmod_path((s1/sys/lib/python2.7/site-packages/nose/importer.pyR*ss  N( t__name__t __module__t__doc__R RRRR<R*(((s1/sys/lib/python2.7/site-packages/nose/importer.pyR s    9 cCs)tjd|ƒ|sgSg}tjj|ƒ}|rstjjtjj|dƒƒrs|jt||ƒƒnB|t jkrµtjd|ƒt jj d|ƒ|j |ƒn|r%|j r%x^|j D]P}tjj||ƒ}tjj |ƒrÎt jj d|ƒ|j |ƒqÎqÎWn|S(slEnsure that the path, or the root of the current package (if path is in a package), is in sys.path. s Add path %ss __init__.pysinsert %s into sys.pathi(R#R$RRR;texistsRtextendR(R%tinsertR>tsrcDirsR:(RRtaddedR4R;tdirpath((s1/sys/lib/python2.7/site-packages/nose/importer.pyR(ˆs&!cCs7tjd|ƒ|tjkr3tjj|ƒndS(NsRemove path %s(R#R$R%Rtremove(R((s1/sys/lib/python2.7/site-packages/nose/importer.pyt remove_path¤s(RFtloggingRR%t nose.configRtimpRRRRt getLoggerRDR#RtsamefileR tAttributeErrortobjectR R R(RN(((s1/sys/lib/python2.7/site-packages/nose/importer.pyts   "  p