ó EÑÕfc@s{dZddlZddlZddlmZyddlmZWn!ek reddlmZnXddgZdefd„ƒYZ d efd „ƒYZ dddddd „Z dddddd „Z d „Zd„Zd„Zed„Zdded„Zd„Zd„Zddd„ZedkrweejƒdkrYejdIJqwejd=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(s get_filenames _get_filename(tgetattrR (tloaderRtattrtmeth((s/usr/lib64/python2.7/runpy.pyR/\s   cCsüt|ƒ}|dkr+td|ƒ‚n|j|ƒr¯|dksU|jdƒrdtdƒ‚ny|d}t|ƒSWq¯tk r«}tdd||fƒ‚q¯Xn|j|ƒ}|dkrÝtd|ƒ‚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 ImportErrort is_packagetendswitht_get_module_detailstget_codeR/(RR1t pkg_main_nameteR"tfilename((s/usr/lib64/python2.7/runpy.pyR8ds"    cCscd}yt|ƒSWnHtk r^}|t|ƒkrXtd|tjdfƒ‚n‚nXdS(NR4scan't find %r module in %ri(R8R5tstrR tpath(t main_nametexc((s/usr/lib64/python2.7/runpy.pyt_get_main_module_detailsxsc Cs×yF|s|dkr0t|ƒ\}}}}ntƒ\}}}}Wn9tk r}dtjt|ƒf}tj|ƒnX|jdƒd}tjdj }|r»|tj diR4Nt(R RTt isinstanceRROR\R-R R>tinsertRRARRRR)R(R*tremovet ValueError( RPR$RKRRR"R?t saved_mainRR1RGR'R+R,((s/usr/lib64/python2.7/runpy.pyRßs0         & R4is!No module specified for executioni(RR RtpkgutilRRR5t__all__RRRR R(R-R/R8RAtTrueRJtFalseRRTR\RRtlenRtstderr(((s/usr/lib64/python2.7/runpy.pyts<           1