Your IP : 18.227.140.152


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/runpy.cpython-34.pyo

�
e f@*�@smdZddlZddlZddlZddlZddlmZmZddgZ	Gdd�de
�ZGdd	�d	e
�Zdddddd
d�Z
ddddddd
�Zdd�Zddd�Zddddd�Zdd�Zdd�Zdddd�Zedkrieej�dkrKeddej�qiejd=eejd�ndS)aZrunpy.py - locating and running Python code using the module namespace

Provides support for locating and running Python scripts using the Python
module namespace instead of the native filesystem.

This allows Python code to play nicely with non-filesystem based PEP 302
importers when locating support scripts as well as when importing modules.
�N)�	read_code�get_importer�
run_module�run_pathc@s:eZdZdZdd�Zdd�Zdd�ZdS)	�_TempModulezCTemporarily replace a module in sys.modules with an empty namespacecCs(||_tj|�|_g|_dS)N)�mod_name�types�
ModuleType�module�
_saved_module)�selfr�r
�*/opt/alt/python34/lib64/python3.4/runpy.py�__init__s	z_TempModule.__init__cCsM|j}y|jjtj|�Wntk
r8YnX|jtj|<|S)N)rr�append�sys�modules�KeyErrorr
)rrr
r
r�	__enter__s	
z_TempModule.__enter__cGs=|jr#|jdtj|j<n
tj|j=g|_dS)Nr)rrrr)r�argsr
r
r�__exit__'s	
z_TempModule.__exit__N)�__name__�
__module__�__qualname__�__doc__rrrr
r
r
rrs	rc@s4eZdZdd�Zdd�Zdd�ZdS)�_ModifiedArgv0cCs ||_t�|_|_dS)N)�value�object�_saved_value�	_sentinel)rrr
r
rr/s	z_ModifiedArgv0.__init__cCsE|j|jk	r!td��ntjd|_|jtjd<dS)NzAlready preserving saved valuer)rr�RuntimeErrorr�argvr)rr
r
rr3sz_ModifiedArgv0.__enter__cGs |j|_|jtjd<dS)Nr)rrrrr!)rrr
r
rr9sz_ModifiedArgv0.__exit__N)rrrrrrr
r
r
rr.src
Cs�|dk	r|j|�n|dkr=d}|}d}	n3|j}|j}|j}	|dkrp|j}n|jd|d|d|	ddd|d|d|�t||�|S)	z)Helper to run code in nominated namespaceNr�__file__�
__cached__r�
__loader__�__package__�__spec__)�update�loader�origin�cached�parent�exec)
�codeZrun_globals�init_globalsr�mod_spec�pkg_name�script_namer(�fnamer*r
r
r�	_run_code>s(				
r3c	Csu|dkr|n|j}t|��B}t|��-|jj}t|||||||�WdQXWdQX|j�S)z5Helper to run code in new namespace with sys modifiedN)r)rrr
�__dict__r3�copy)	r-r.rr/r0r1r2�temp_module�mod_globalsr
r
r�_run_module_codeXsr8cCs�ytjj|�}Wn[ttttfk
rs}z/d}t|j|t|�|��|�WYdd}~XnX|dkr�td|��n|j	dk	r)|dks�|j
d�r�td��ny|d}t|�SWq)tk
r%}ztdd||f��WYdd}~Xq)Xn|j}|dkrQtd|��n|j
|�}|dkrtd	|��n|||fS)
Nz*Error while finding spec for {!r} ({}: {})zNo module named %s�__main__z	.__main__z%Cannot use package as __main__ modulez%s; %r is a package and cannot zbe directly executedz0%r is a namespace package and cannot be executedzNo code object available for %s)�	importlib�util�	find_spec�ImportError�AttributeError�	TypeError�
ValueError�format�type�submodule_search_locations�endswith�_get_module_detailsr(�get_code)r�specZex�msgZ
pkg_main_name�er(r-r
r
rrEfs07
*	
rETcCs�y@|s|dkr-t|�\}}}nt�\}}}Wnktk
r�}zK|rjt|�}ndtjd}dtj|f}tj|�WYdd}~XnXtjdj	}|r�|j
tjd<nt||dd|�S)a�Runs the designated module in the __main__ namespace

       Note that the executed module will have full access to the
       __main__ namespace. If this is not desirable, the run_module()
       function should be used to run the module code in a fresh namespace.

       At the very least, these variables in __main__ will be overwritten:
           __name__
           __file__
           __cached__
           __loader__
           __package__
    r9z"can't find '__main__' module in %rrz%s: %sN)rE�_get_main_module_detailsr=�strrr!�
executable�exitrr4r)r3)rZ
alter_argvr/r-�exc�inforHZmain_globalsr
r
r�_run_module_as_main�s rPFcCs]t|�\}}}|dkr*|}n|rCt||||�St|i|||�SdS)znExecute a module's code without importing it

       Returns the resulting top level namespace dictionary
    N)rEr8r3)rr.�run_nameZ	alter_sysr/r-r
r
rr�s	cCs�d}tj|}tj|=zryt|�SWn]tk
r�}z=|t|�krxtd|tjdf�|�n�WYdd}~XnXWd|tj|<XdS)Nr9zcan't find %r module in %rr)rrrEr=rK�path)Z	main_nameZ
saved_mainrNr
r
rrJ�s

rJcCsmt|d��}t|�}WdQX|dkrct|d��}t|j�|d�}WdQXn||fS)N�rbr,)�openr�compile�read)rQr2�fr-r
r
r�_get_code_from_file�s!rXcCsi|dkrd}n|jd�d}t|�}d}t|�jdkrpt|�jdkrpd}qpnt|td��s�|r�t||�\}}t|||d	|d
|�Stj	j
d|�zit�\}}	}t|��E}
t
|��0|
jj}t|||||	|�j�SWdQXWdQXWdytj	j|�Wntk
rcYnXXdS)a_Execute code located at the specified filesystem location

       Returns the resulting top level namespace dictionary

       The file path may refer directly to a Python script (i.e.
       one that could be directly executed with execfile) or else
       it may refer to a zipfile or directory containing a top
       level __main__.py script.
    Nz
<run_path>�.rFZimpZNullImporterTr0r1)�
rpartitionrrBrr�
isinstancerXr8rrR�insertrJrrr
r4r3r5�remover@)Z	path_namer.rQr0ZimporterZis_NullImporterr-r2rr/r6r7r
r
rr�s0
	

#
r9�z!No module specified for execution�file)rr�importlib.machineryr:�importlib.utilrZpkgutilrr�__all__rrrr3r8rErPrrJrXrr�lenr!�print�stderrr
r
r
r�<module>s4!%
1


?>