a DOg~)@sddlZddlZddlmZmZgdZGdddZGdddeZddd Ze d krddl Z e Z e j d d d de ZejsejjrdZndZeedS)N)CommandCompilercompile_command)InteractiveInterpreterInteractiveConsoleinteractrc@sBeZdZdddZdddZdd Zdd d Zd d ZddZdS)rNcCs$|durddd}||_t|_dS)NZ __console__)__name____doc__)localsrcompile)selfr r /usr/lib64/python3.9/code.py__init__s  zInteractiveInterpreter.__init__singlec CsRz||||}Wn$tttfy6||YdS0|durDdS||dS)NFT)r OverflowError SyntaxError ValueErrorshowsyntaxerrorruncode)r sourcefilenamesymbolcoder r r runsource&s  z InteractiveInterpreter.runsourcecCs<zt||jWn&ty$Yn|Yn0dSN)execr SystemExit showtraceback)r rr r r rMs  zInteractiveInterpreter.runcodec Cst\}}}|t_|t_|t_|rn|turnz|j\}\}}}} WntyTYn0t||||| f}|t_tjtj urt ||} | d | nt|||dS)N)sysexc_info last_type last_valuelast_tracebackrargsr excepthook__excepthook__ tracebackformat_exception_onlywritejoin) r rtypevaluetbmsgZdummy_filenamelinenooffsetlinelinesr r r r`s     z&InteractiveInterpreter.showsyntaxerrorcCst\t_t_}}|t_zXt|d|d|j}tjtj urT| d |nt|d|d|Wd}}n d}}0dS)Nrr) r r!r"r#r$r(format_exceptiontb_nextr&r'r*r+)r Zlast_tbeir3r r r rs z$InteractiveInterpreter.showtracebackcCstj|dSr)r stderrr*)r datar r r r*szInteractiveInterpreter.write)N)rr)N) r __module__ __qualname__rrrrrr*r r r r rs   ' #rc@s:eZdZdddZddZdddZd d Zdd d ZdS)rN cCst||||_|dSr)rrr resetbuffer)r r rr r r rs zInteractiveConsole.__init__cCs g|_dSr)buffer)r r r r r=szInteractiveConsole.resetbuffercCsJz tjWnty"dt_Yn0z tjWntyFdt_Yn0d}|durt|dtjtj||jjfn|r|dt |d}zT|rtj}ntj}z| |}Wn$t y|dYWqYn 0| |}Wqt y |d|d}Yq0q|dur.|d |jjn|d krF|d|dS) Nz>>> z... zFType "help", "copyright", "credits" or "license" for more information.zPython %s on %s %s (%s) z%s r z KeyboardInterrupt znow exiting %s... r)r Zps1AttributeErrorZps2r*versionplatform __class__rstr raw_inputEOFErrorpushKeyboardInterruptr=)r bannerexitmsgZcprtmorepromptr2r r r rsH             zInteractiveConsole.interactcCs6|j|d|j}|||j}|s2||S)Nr?)r>appendr+rrr=)r r2rrKr r r rGs   zInteractiveConsole.pushrcCst|Sr)input)r rLr r r rEs zInteractiveConsole.raw_input)Nr<)NN)r)rr:r;rr=rrGrEr r r r rs   6rcCsHt|}|dur||_n z ddl}Wnty6Yn0|||dS)Nr)rrEreadline ImportErrorr)rIZreadfunclocalrJZconsolerOr r r rs  r__main__z-q store_truez*don't print version and copyright messages)actionhelpr)NNNN)r r(Zcodeoprr__all__rrrrargparseArgumentParserparser add_argument parse_argsr%qflagsquietrIr r r r s$t