Your IP : 216.73.216.61


Current Path : /opt/alt/python35/lib/python3.5/site-packages/nose/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/nose/__pycache__/importer.cpython-35.pyc



d�UZ�@s�dZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
eje�Z
yejjZWnek
r�dd�ZYnXGdd�de�Zdd	d
�Zdd�ZdS)
a: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.
�N)�Config)�find_module�load_module�acquire_lock�release_lockcCs:tjjtjj|��tjjtjj|��kS)N)�os�path�normcase�realpath)�src�dst�r
�>/opt/alt/python35/lib/python3.5/site-packages/nose/importer.py�	_samefilesrc@sUeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�ZdS)
�Importerz�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.
    NcCs"|dkrt�}||_dS)N)r�config)�selfrr
r
r�__init__s	zImporter.__init__cCs�tjjtjj|��jtj�}|jd�}|ddkrS|j�|dt|��}tjj|�}|j	||�S)z�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.
        �.�z__init__.pyN���)
rr�normpath�abspath�split�sep�pop�len�join�
importFromDir)rr�fqname�
path_partsZ
name_partsZdir_pathr
r
r�importFromPath"s*
zImporter.importFromPathc

Cs�tjjtjj|��}tjd||�|dkrHtj|S|jj	rdt
||j�|g}|jd�}d}d}}}x\|D]T}	|dkr�|	}nd||	f}z�t�tjd|	||�t
|	|�\}}
}tjj|�}|dk	r�tjd||�|j||
�s[|jjrdt|d	d�rd|}q�tj|=t|||
|�}nt|||
|�}Wd|r�|j�t�X|r�t||	|�t|d	�r�|j}|}q�W|S)
z�Import a module *only* from path, ignoring sys.path and
        reloading if the version in sys.modules is not the one we want.
        zImport %s from %s�__main__r�Nz%s.%szfind module part %s (%s) in %szsys.modules has %s as %s�__path__)rrrr�log�debug�sys�modulesrZaddPaths�add_pathrrr�get�
sameModuleZfirstPackageWins�getattrr�closer�setattr�hasattrr$)
r�dirrr�partsZpart_fqname�mod�parentZfh�part�filename�desc�oldr
r
rr1sL	
		
	

	
zImporter.importFromDircCs*tjj|�r|Stjj|�SdS)N)rr�isdir�dirname)rr5r
r
r�_dirname_if_filejszImporter._dirname_if_filecCs�g}t|d�rBxY|jD]}|j|j|��qWn/t|d�rm|j|j|j��ndS|j|�}x4|D],}tjd||�t||�r�dSq�WdS)Nr$�__file__Fz&module already loaded? mod: %s new: %sT)r/r$�appendr:r;r%r&r)rr2r5Z	mod_pathsr�new_pathZmod_pathr
r
rr+ss

zImporter.sameModule)	�__name__�
__module__�__qualname__�__doc__rr!rr:r+r
r
r
rrs9	rcCs tjd|�|sgSg}tjj|�}|rstjjtjj|d��rs|jt||��n?|t	jkr�tjd|�t	jj
d|�|j|�|r|jrxX|jD]M}tjj||�}tjj
|�r�t	jj
d|�|j|�q�W|S)zlEnsure that the path, or the root of the current package (if
    path is in a package), is in sys.path.
    zAdd path %sz__init__.pyzinsert %s into sys.pathr)r%r&rrr9�existsr�extendr)r'�insertr<ZsrcDirsr8)rrZaddedr3r9�dirpathr
r
rr)�s&!
r)cCs4tjd|�|tjkr0tjj|�dS)NzRemove path %s)r%r&r'r�remove)rr
r
r�remove_path�srG)rA�loggingrr'Znose.configr�imprrrr�	getLoggerr>r%r�samefiler�AttributeError�objectrr)rGr
r
r
r�<module>s"
p