]'@sddlZddlZddlZddlmZmZddddgZGdddZGdddeZdddd dZ e d krej Z e j d d d dde jZejsejjrdZndZe edS)N)CommandCompilercompile_commandInteractiveInterpreterInteractiveConsoleinteractrc@sdeZdZdddZddddZdd Zdd d Zd d ZddZdS)rNcCs7|dkrddddi}||_t|_dS)N__name__Z __console____doc__)localsrcompile)selfr r )/opt/alt/python35/lib64/python3.5/code.py__init__s  zInteractiveInterpreter.__init__zZsinglec Csiy|j|||}Wn,tttfk rG|j|dSYnX|dkrXdS|j|dS)NFT)r OverflowError SyntaxError ValueErrorshowsyntaxerrorruncode)r sourcefilenamesymbolcoder r r runsource's    z InteractiveInterpreter.runsourcec CsAyt||jWn&tk r+Yn|jYnXdS)N)execr SystemExit showtraceback)r rr r r rNs  zInteractiveInterpreter.runcodec Cstj\}}}|t_|t_|t_|r|tkry|j\}\}}}} Wntk ruYn%Xt||||| f}|t_tjtj krt j ||} |j dj | ntj|||dS)N)sysexc_info last_type last_valuelast_tracebackrargsr excepthook__excepthook__ tracebackformat_exception_onlywritejoin) r rtypevaluetbmsgZdummy_filenamelinenooffsetlinelinesr r r ras      z&InteractiveInterpreter.showsyntaxerrorc Cstj\t_t_}}|t_zjtj|d|d|j}tjtj krv|j dj |ntj|d|d|Wdd}}XdS)Nrr) rrrr r!r%format_exceptiontb_nextr#r$r'r()r Zlast_tbeir0r r r rs  z$InteractiveInterpreter.showtracebackcCstjj|dS)N)rstderrr')r datar r r r'szInteractiveInterpreter.write) r __module__ __qualname__rrrrrr'r r r r rs ' # c@sXeZdZddddZddZdddZd d Zd d d ZdS)rNz cCs'tj||||_|jdS)N)rrr resetbuffer)r r rr r r rs  zInteractiveConsole.__init__cCs g|_dS)N)buffer)r r r r r9szInteractiveConsole.resetbufferc!CsTy tjWntk r(dt_YnXy tjWntk rQdt_YnXd}|dkr|jdtjtj||jjfn|r|jdt |d}xyd|rtj}n tj}y|j |}Wn t k r |jdPYnX|j |}Wqt k rK|jd|jd}YqXqWdS) Nz>>> z... zFType "help", "copyright", "credits" or "license" for more information.zPython %s on %s %s (%s) z%s r z KeyboardInterrupt )rZps1AttributeErrorZps2r'versionplatform __class__rstr raw_inputEOFErrorpushKeyboardInterruptr9)r bannerZcprtmorepromptr/r r r rs>              zInteractiveConsole.interactcCsK|jj|dj|j}|j||j}|sG|j|S)Nr;)r:appendr(rrr9)r r/rrFr r r rCs  zInteractiveConsole.pushrcCs t|S)N)input)r rGr r r rAs zInteractiveConsole.raw_input)rr7r8rr9rrCrAr r r r rs  - c CsZt|}|dk r$||_n%yddl}Wntk rHYnX|j|dS)Nr)rrAreadline ImportErrorr)rEZreadfunclocalZconsolerJr r r rs    __main__z-qaction store_truehelpz*don't print version and copyright messagesr)rr%argparseZcodeoprr__all__rrrrArgumentParserparser add_argument parse_argsr"qflagsquietrEr r r r s"     k