Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/nose/importer.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�9�c@s�dZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
eje�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(tfind_moduletload_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}|jd�}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"(
RtdirRRtpartstpart_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$RtTrue(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.
    sAdd 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.pytremove_path�s(RFtloggingRR%tnose.configRtimpRRRRt	getLoggerRDR#RtsamefileRtAttributeErrortobjectRR
R(RN(((s1/sys/lib/python2.7/site-packages/nose/importer.pyt<module>s"

p

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.