grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026î   f@*ã@smdZddlZddlZddlZddlZddlmZmZddgZ Gdd„de ƒZ Gdd „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__c CsM|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|js(         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Ú.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Ús4      !%  1