ó 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|js 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't temp_modulet mod_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_packaget ImportErrortformattendswitht __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 diR4Nt(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.pyts>           1