a DOg3@sddlZddlZddlZddlZddlZddlZddlmZm Z ddgZ Gddde Z Gddde Z dd d Zd d d Zefd dZGdddeZd!ddZd"ddZefddZddZd#ddZedkr eejdkredejdnejd=eejddS)$N) read_code get_importer run_modulerun_pathc@s$eZdZddZddZddZdS) _TempModulecCs||_t||_g|_dSN)mod_nametypes ModuleTypemodule _saved_moduleselfrr*/opt/alt/python39/lib64/python3.9/runpy.py__init__s z_TempModule.__init__cCs@|j}z|jtj|Wnty.Yn0|jtj|<|Sr)rr appendsysmodulesKeyErrorr r rrr __enter__ s  z_TempModule.__enter__cGs.|jr|jdtj|j<n tj|j=g|_dSNr)r rrrrargsrrr__exit__)s z_TempModule.__exit__N__name__ __module__ __qualname__rrrrrrrrs rc@s$eZdZddZddZddZdS)_ModifiedArgv0cCs||_t|_|_dSr)valueobject _saved_value _sentinel)rr rrrr1sz_ModifiedArgv0.__init__cCs0|j|jurtdtjd|_|jtjd<dS)NzAlready preserving saved valuer)r"r# RuntimeErrorrargvr )rrrrr5s  z_ModifiedArgv0.__enter__cGs|j|_|jtjd<dSr)r#r r"rr%rrrrr;sz_ModifiedArgv0.__exit__Nrrrrrr0src Csn|dur|||dur(d}|}d} n |j}|j}|j} |durH|j}|j||| d|||dt|||S)N)r__file__ __cached____doc__ __loader__ __package____spec__)updateloaderorigincachedparentexec) codeZ run_globals init_globalsrmod_specpkg_name script_namer-fnamer/rrr _run_code@s*  r8c Cs|dur |n|j}t|T}t|,|jj}t|||||||Wdn1sV0YWdn1st0Y|Sr)r.rrr __dict__r8copy) r2r3rr4r5r6r7 temp_module mod_globalsrrr_run_module_codeZs@r=c Csd|dr|d|d\}}}|rz t|WnJty|}z2|jdusf|j|krh||jdshWYd}~n d}~00tj|}|durt|dsddl m }dj ||d}|t |zt j|}WnvttttfyH} zTd}|d r|d |dd d |d 7}|| |t| j| | WYd} ~ n d} ~ 00|dur`|d||jdur|dks|dr|dz|d} t| |WS|y}z*|tjvr|d||fWYd}~n d}~00|j} | dur|d|z| |} Wn4tyB}z|t ||WYd}~n d}~00| durZ|d|||| fS)N.z#Relative module names not supported__path__r)warnz{mod_name!r} found in sys.modules after import of package {pkg_name!r}, but prior to execution of {mod_name!r}; this may result in unpredictable behaviour)rr5z:Error while finding module specification for {!r} ({}: {})z.pyz . Try using 'z' instead of 'z' as the module name.zNo module named %s__main__z .__main__z%Cannot use package as __main__ modulez3%s; %r is a package and cannot be directly executedz0%r is a namespace package and cannot be executedzNo code object available for %s) startswith rpartition __import__ ImportErrornamerrgethasattrwarningsr@formatRuntimeWarning importlibutil find_specAttributeError TypeError ValueErrorendswithtypersubmodule_search_locations_get_module_detailsr-get_code) rerrorr5_eZexistingr@msgspecZexZ pkg_main_namer-r2rrrrVhsj       0      $  rVc@s eZdZdS)_ErrorN)rrrrrrrr]sr]Tc Csz0|s|dkr t|t\}}}ntt\}}}Wn<tyl}z$dtj|f}t|WYd}~n d}~00tjdj}|r|jtj d<t ||dd|S)NrBz%s: %sr) rVr]_get_main_module_detailsr executableexitrr9r.r%r8)rZ alter_argvr4r2excr[Z main_globalsrrr_run_module_as_mains    rbFcCs@t|\}}}|dur|}|r,t||||St|i|||SdSr)rVr=r8)rr3run_nameZ alter_sysr4r2rrrrs c Csd}tj|}tj|=zpzt|WW|tj|<Styx}z2|t|vrb|d|tjdf|WYd}~n d}~00W|tj|<n |tj|<0dS)NrBzcan't find %r module in %rr)rrrVrFstrpath)rXZ main_nameZ saved_mainrarrrr^s      r^cCstjt|}t|}t|}Wdn1s:0Y|durt| }t||d}Wdn1s|0Y||fS)Nr1) osreabspathfsdecodeio open_codercompileread)rcr7Z decoded_pathfr2rrr_get_code_from_files & .rnc Cs|dur d}|dd}t|}d}t|jdkrFt|jdkrFd}t|tdsX|rxt||\}}t|||||dStj d|zt \}} }t |} t |d| jj} t|| ||| |WdWdWztj |WStyYS0S1s0YWdn1s20YWztj |WntybYn0n(ztj |WntyYn00dS) Nz r>rFZimpZ NullImporterT)r5r6)rDrrTrr isinstancernr=rreinsertr^rrr r9r8r:removerR) Z path_namer3rcr5ZimporterZis_NullImporterr2r7rr4r;r<rrrrsH  $6rBz!No module specified for execution)file)NNNNN)NNNNN)T)NNF)NN)rimportlib.machineryrMimportlib.utilrir rfZpkgutilrr__all__r!rrr8r=rFrV Exceptionr]rbrr^rnrrlenr%printstderrrrrr s@   =    6