ok

Mini Shell

Direktori : /lib64/python2.7/
Upload File :
Current File : //lib64/python2.7/runpy.pyc

�
zfc@s�dZddlZddlZddlmZyddlmZWn!ek
reddlmZnXddgZdefd��YZ	d	efd
��YZ
dddddd�Zdddddd�Z
d
�Zed�Zed�Zdefd��YZed�Zdded�Zd�Zd�Zddd�Zedkr�eej�dkruejdIJq�ejd=eejd�ndS(sZrunpy.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.
i����N(t	read_code(t
get_loadert
run_moduletrun_patht_TempModulecBs)eZdZd�Zd�Zd�ZRS(sCTemporarily replace a module in sys.modules with an empty namespacecCs(||_tj|�|_g|_dS(N(tmod_nametimpt
new_moduletmodulet
_saved_module(tselfR((s/usr/lib64/python2.7/runpy.pyt__init__s	cCsL|j}y|jjtj|�Wntk
r7nX|jtj|<|S(N(RR	tappendtsystmodulestKeyErrorR(R
R((s/usr/lib64/python2.7/runpy.pyt	__enter__s	
cGs=|jr#|jdtj|j<n
tj|j=g|_dS(Ni(R	R
RR(R
targs((s/usr/lib64/python2.7/runpy.pyt__exit__(s	
(t__name__t
__module__t__doc__RRR(((s/usr/lib64/python2.7/runpy.pyRs			t_ModifiedArgv0cBs#eZd�Zd�Zd�ZRS(cCs ||_t�|_|_dS(N(tvaluetobjectt_saved_valuet	_sentinel(R
R((s/usr/lib64/python2.7/runpy.pyR0s	cCsE|j|jk	r!td��ntjd|_|jtjd<dS(NsAlready preserving saved valuei(RRtRuntimeErrorR
targvR(R
((s/usr/lib64/python2.7/runpy.pyR4scGs |j|_|jtjd<dS(Ni(RRRR
R(R
R((s/usr/lib64/python2.7/runpy.pyR:s(RRRRR(((s/usr/lib64/python2.7/runpy.pyR/s		c	BsJ|dk	r|j|�n|jd|d|d|d|�||U|S(s)Helper to run code in nominated namespaceRt__file__t
__loader__t__package__N(tNonetupdate(tcodetrun_globalstinit_globalsRt	mod_fnamet
mod_loadertpkg_name((s/usr/lib64/python2.7/runpy.pyt	_run_code>scCsZt|��B}t|��-|jj}t|||||||�WdQXWdQX|j�S(s5Helper to run code in new namespace with sys modifiedN(RRRt__dict__R(tcopy(R"R$RR%R&R'ttemp_moduletmod_globals((s/usr/lib64/python2.7/runpy.pyt_run_module_codeKs
cCs=x6dD].}t||d�}|dk	r||�SqWdS(Ntget_filenamet
_get_filename(R.R/(tgetattrR (tloaderRtattrtmeth((s/usr/lib64/python2.7/runpy.pyR/\s

cCsdy>t|�}|dkr.|d|��n|j|�}Wn%tk
re}|t|���nX|r�|dks�|jd�r�|d��nt|�y|d}t|�SWq�tk
r�}|dd||f��q�Xny|j|�}Wn%tk
r%}|t|���nX|dkrE|d|��nt	||�}||||fS(NsNo module named %st__main__s	.__main__s%Cannot use package as __main__ modules%s; %r is a package and cannot sbe directly executedsNo code object available for %s(
RR t
is_packagetImportErrortformattendswitht
__import__t_get_module_detailstget_codeR/(RterrorR1tispkgtet
pkg_main_nameR"tfilename((s/usr/lib64/python2.7/runpy.pyR:ds2

cCscd}yt|�SWnHtk
r^}|t|�krX|d|tjdf��n�nXdS(NR4scan't find %r module in %ri(R:R6tstrR
tpath(R<t	main_nametexc((s/usr/lib64/python2.7/runpy.pyt_get_main_module_details�st_ErrorcBseZdZRS(sBError that _run_module_as_main() should report without a traceback(RRR(((s/usr/lib64/python2.7/runpy.pyRF�sc	Cs�yL|s|dkr3t|t�\}}}}ntt�\}}}}Wn3tk
r�}dtj|f}tj|�nX|jd�d}tjdj}|r�|tj	d<nt
||dd|||�S(s�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__
           __loader__
           __package__
    R4s%s: %st.iN(R:RFRER
t
executabletexitt
rpartitionRR)RR(R (	Rt
alter_argvR1R"tfnameRDtmsgR'tmain_globals((s/usr/lib64/python2.7/runpy.pyt_run_module_as_main�s
cCst|�\}}}}|dkr-|}n|jd�d}|r_t||||||�St|i|||||�SdS(snExecute a module's code without importing it

       Returns the resulting top level namespace dictionary
    RGiN(R:R RJR-R((RR$trun_namet	alter_sysR1R"RLR'((s/usr/lib64/python2.7/runpy.pyR�s	
cCs�tj}y||}Wn�tk
r�d||<x^tjD]+}y||�}PWq;tk
req;Xq;Wytj|�}Wntk
r�dSX|||<nX|S(s5Python version of PyImport_GetImporter C API functionN(R
tpath_importer_cacheRR t
path_hooksR6RtNullImporter(t	path_nametcachetimporterthook((s/usr/lib64/python2.7/runpy.pyt
_get_importer�s"	



c	Csgt|d��}t|�}WdQX|dkrct|d��}t|j�|d�}WdQXn|S(NtrbtrUtexec(topenRR tcompiletread(RLtfR"((s/usr/lib64/python2.7/runpy.pyt_get_code_from_file�s!c
Cs<|dkrd}nt|�}t|tj�rRt|�}t||||�Stjj	d|�z�d}tj
|}tj
|=zt�\}}}}	Wd|tj
|<Xd}
t|��H}t
|��3|jj}t|||||	||
�j�SWdQXWdQXWdytjj|�Wntk
r6nXXdS(s_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.
    s
<run_path>iR4Nt(R RYt
isinstanceRRTRaR-R
RBtinsertRRERRRR)R(R*tremovet
ValueError(
RUR$RPRWR"RCt
saved_mainRR1RLR'R+R,((s/usr/lib64/python2.7/runpy.pyR�s0
	


&
R4is!No module specified for executioni(RR
RtpkgutilRRR6t__all__RRRR R(R-R/R:REt	ExceptionRFtTrueROtFalseRRYRaRRtlenRtstderr(((s/usr/lib64/python2.7/runpy.pyt<module>s>
			
1


Zerion Mini Shell 1.0