Ë ‚Ö¦iÒ*ãó>—dZddlZddlZddlmZmZgd¢ZGd„d«ZGd„de«Zdd „Z e d k(riddl Z e j«Z e jd d d ¬«e j«Zej"sej$j&rdZndZe e«yy)z?Utilities needed to emulate Python's interactive interpreter. éN)ÚCommandCompilerÚcompile_command)ÚInteractiveInterpreterÚInteractiveConsoleÚinteractrcó@—eZdZdZd d„Zd d„Zd„Zd d„Zd„Zd„Z d „Z y) rz÷Base class for InteractiveConsole. This class deals with parsing and interpreter state (the user's namespace); it doesn't deal with input buffering or prompting or input file naming (the filename is always passed in explicitly). Ncó>—|€dddœ}||_t«|_y)aConstructor. The optional 'locals' argument specifies the dictionary in which code will be executed; it defaults to a newly created dictionary with key "__name__" set to "__console__" and key "__doc__" set to None. NÚ __console__)Ú__name__Ú__doc__)ÚlocalsrÚcompile)Úselfr s ú/usr/lib64/python3.12/code.pyÚ__init__zInteractiveInterpreter.__init__s$€ð ˆ>Ø"/¸DÑAˆF؈Œ Ü&Ó(ˆ� ócóª— |j|||«}|€y|j |«y#tttf$r|j |«YywxYw)aˆCompile and run some source in the interpreter. Arguments are as for compile_command(). One of several things can happen: 1) The input is incorrect; compile_command() raised an exception (SyntaxError or OverflowError). A syntax traceback will be printed by calling the showsyntaxerror() method. 2) The input is incomplete, and more input is required; compile_command() returned None. Nothing happens. 3) The input is complete; compile_command() returned a code object. The code is executed by calling self.runcode() (which also handles run-time exceptions, except for SystemExit). The return value is True in case 2, False in the other cases (unless an exception is raised). The return value can be used to decide whether to use sys.ps1 or sys.ps2 to prompt the next line. FT)rÚ OverflowErrorÚ SyntaxErrorÚ ValueErrorÚshowsyntaxerrorÚruncode)rÚsourceÚfilenameÚsymbolÚcodes rÚ runsourcez InteractiveInterpreter.runsource&s]€ð0 Ø—<‘< ¨°&Ó9ˆDð ˆ<àð � ‰ �TÔØøôœ{¬JÐ7ò à × Ñ  Ô *Ùð ús‚*ª%AÁAcór— t||j«y#t$r‚|j«YyxYw)aƒExecute a code object. When an exception occurs, self.showtraceback() is called to display a traceback. All exceptions are caught except SystemExit, which is reraised. A note about KeyboardInterrupt: this exception may occur elsewhere in this code, and may not always be caught. The caller should be prepared to deal with it. N)Úexecr Ú SystemExitÚ showtraceback)rrs rrzInteractiveInterpreter.runcodeMs3€ð !Ü ��t—{‘{Õ #øÜò Ø ð !Ø × Ñ Ö ús‚™6cóú— tj«\}}}|r-|tur% |j\}\}}}} t||||| f«}|j ||d«dx}x}}y#t$rYŒ%wxYw#dx}x}}wxYw)apDisplay the syntax error that just occurred. This doesn't display a stack trace because there isn't one. If a filename is given, it is stuffed in the exception instead of what was there before (because Python's parser always uses "" when reading from a string). The output is written by self.write(), below. N)ÚsysÚexc_inforÚargsrÚ_showtraceback) rrÚtypÚvalueÚtbÚmsgÚdummy_filenameÚlinenoÚoffsetÚlines rrz&InteractiveInterpreter.showsyntaxerror`s�€ð $Ü Ÿ\™\›^‰NˆC�˜Ù˜C¤;Ñ.ðOØBGÇ*Á*Ñ?�CÑ?˜.¨&°&¸$ô (¨¨h¸ÀÈÐ-MÓN�EØ × Ñ   U¨DÔ 1à#Ð #ˆCÐ #�%™"øô"òáðûð $Ð #ˆCÐ #�%™"ús-‚"A2¥A#¹#A2Á# A/Á,A2Á.A/Á/A2Á2A:có’— tj«\}}}|j|||j«dx}x}}y#dx}x}}wxYw)z®Display the exception that just occurred. We remove the first stack item because it is our own code. The output is written by self.write(), below. N)r#r$r&Útb_next)rr'r(r)s rr!z$InteractiveInterpreter.showtraceback|sM€ð $Ü Ÿ\™\›^‰NˆC�˜Ø × Ñ   U¨B¯J©JÔ 7à#Ð #ˆCÐ #�%™"ø˜tÐ #ˆCÐ #�%™"ús ‚5>¾Acó—|t_|t_|j|«xt_xt_}tj tjur8tj|||«}|jdj|««y tj |||«y#t$r‚t$rÇ}d|_|j|jj «}t#dtj$¬«tjt'|«||j«t#tj$¬«t#dtj$¬«tj|||«Yd}~yd}~wwxYw)NÚzError in sys.excepthook:)ÚfilezOriginal exception was:)r#Ú last_typeÚlast_tracebackÚwith_tracebackÚlast_excÚ last_valueÚ excepthookÚ__excepthook__Ú tracebackÚformat_exceptionÚwriteÚjoinr Ú BaseExceptionÚ __context__Ú __traceback__r0ÚprintÚstderrÚtype)rr'r(r)ÚlinesÚes rr&z%InteractiveInterpreter._showtracebackŠs€ØŒŒ ØŒÔØ05×0DÑ0DÀRÓ0HÐHŒŒ ÐH”s”~¨Ü �>‰>œS×/Ñ/Ñ /Ü×.Ñ.¨s°E¸2Ó>ˆEØ �J‰J�r—w‘w˜u“~Õ &ð 3Ü—‘˜s E¨2Õ.øÜò ØÜ ò 3Ø $�” Ø×$Ñ$ Q§_¡_×%<Ñ%<Ó=�ÜÐ0´s·z±zÕBÜ×"Ñ"¤4¨£7¨A¨q¯©Ô?Üœ3Ÿ:™:Õ&ÜÐ/´c·j±jÕAÜ×"Ñ" 3¨¨r×2Ñ2ûð 3úsÂB/Â/FÃB=FÆFcóB—tjj|«y)z•Write a string. The base implementation writes to sys.stderr; a subclass may replace this with a different implementation. N)r#rCr=)rÚdatas rr=zInteractiveInterpreter.write¡s€ô � ‰ ×јÕr)N)zÚsingle) r Ú __module__Ú __qualname__r rrrrr!r&r=©rrrrs+„ñó )ó%òN!ó&$ò8 $ò3ó.rrcó4—eZdZdZdd„Zd„Zd d„Zd„Zd d„Zy) rzÎClosely emulate the behavior of the interactive Python interpreter. This class builds on InteractiveInterpreter and adds prompting using the familiar sys.ps1 and sys.ps2, and input buffering. Ncó^—tj||«||_|j«y)zÿConstructor. The optional locals argument will be passed to the InteractiveInterpreter base class. The optional filename argument should specify the (file)name of the input stream; it will show up in tracebacks. N)rrrÚ resetbuffer)rr rs rrzInteractiveConsole.__init__³s'€ô ×'Ñ'¨¨fÔ5Ø ˆŒ Ø ×ÑÕrcó—g|_y)zReset the input buffer.N)Úbuffer)rs rrOzInteractiveConsole.resetbufferÁs €àˆ� rc óZ— tj tjd}|€O|j dtj ›dtj ›d|›d|jj›d � «n|r|j d t|«z«d } |rtj}ntj} |j|«}|j|«} ŒI#t$rdt_YŒåwxYw#t$rdt_YŒîwxYw#t$r|j d«Yn6wxYw#t$r&|j d «|j«d }YŒƒwxYw|€)|j d |jjz«y|dk7r|j d |z«yy)aˆClosely emulate the interactive Python console. The optional banner argument specifies the banner to print before the first interaction; by default it prints a banner similar to the one printed by the real Python interpreter, followed by the current class name in parentheses (so as not to confuse this with the real interpreter -- since it's so close!). The optional exitmsg argument specifies the exit message printed when exiting. Pass the empty string to suppress printing an exit message. If exitmsg is not given or None, a default message is printed. z>>> z... zFType "help", "copyright", "credits" or "license" for more information.NzPython z on Ú z (z) z%s rz KeyboardInterrupt znow exiting %s... r2)r#Úps1ÚAttributeErrorÚps2r=ÚversionÚplatformÚ __class__r ÚstrÚ raw_inputÚpushÚEOFErrorÚKeyboardInterruptrO)rÚbannerÚexitmsgÚcprtÚmoreÚpromptr.s rrzInteractiveConsole.interactÅss€ð  Ü �GŠGð Ü �GŠGðXˆØ ˆ>Ø �JŠJÜŸ › ¤S§\£\²4ØŸ™×/Ó/ð1õ 2ñØ �J‰J�v¤ F£ Ñ+Ô ,؈Øð ÙÜ ŸW™W‘Fä ŸW™W�Fð+ØŸ>™>¨&Ó1�Dð  Ÿ9™9 T›?‘Dðøôò ØŒCŽGð ûôò ØŒCŽGð ûô$ òØ—J‘J˜tÔ$Ùðûô %ò Ø— ‘ Ð2Ô3Ø× Ñ Ô"Ø’ð úð ˆ?Ø �J‰JÐ,¨t¯~©~×/FÑ/FÑFÕ GØ ˜Š]Ø �J‰J�v Ñ'Õ (ðsX‚C!“C;Â#D5Â=DÃD5Ã!C8Ã7C8Ã;DÄDÄD2Ä/D5Ä1D2Ä2D5Ä5,E$Å#E$cóΗ|jj|«dj|j«}|j||j«}|s|j «|S)aPush a line to the interpreter. The line should not have a trailing newline; it may have internal newlines. The line is appended to a buffer and the interpreter's runsource() method is called with the concatenated contents of the buffer as source. If this indicates that the command was executed or invalid, the buffer is reset; otherwise, the command is incomplete, and the buffer is left as it was after the line was appended. The return value is 1 if more input is required, 0 if the line was dealt with in some way (this is the same as runsource()). rS)rQÚappendr>rrrO)rr.rrbs rr\zInteractiveConsole.pushûsP€ð � ‰ ×ј4Ô Ø—‘˜4Ÿ;™;Ó'ˆØ�~‰~˜f d§m¡mÓ4ˆÙØ × Ñ Ô Øˆ rcó—t|«S)aDWrite a prompt and read a line. The returned line does not include the trailing newline. When the user enters the EOF key sequence, EOFError is raised. The base implementation uses the built-in function input(); a subclass may replace this with a different implementation. )Úinput)rrcs rr[zInteractiveConsole.raw_inputs€ô�V‹}Ðr)Nz )NN)r2) r rJrKr rrOrr\r[rLrrrr«s!„ñó òó4)òlô* rrcóz—t|«}|�||_n ddl}|j ||«y#t$rYŒwxYw)a&Closely emulate the interactive Python interpreter. This is a backwards compatible interface to the InteractiveConsole class. When readfunc is not specified, it attempts to import the readline module to enable GNU readline if it is available. Arguments (all optional, all default to None): banner -- passed to InteractiveConsole.interact() readfunc -- if not None, replaces InteractiveConsole.raw_input() local -- passed to InteractiveInterpreter.__init__() exitmsg -- passed to InteractiveConsole.interact() Nr)rr[ÚreadlineÚ ImportErrorr)r_ÚreadfuncÚlocalr`Úconsoleris rrrsJ€ô! Ó'€GØÐØ$ˆÕð Û ð ×Ñ�V˜WÕ%øôò Ù ð ús —.® :¹:Ú__main__z-qÚ store_truez*don't print version and copyright messages)ÚactionÚhelpr2)NNNN)r r#r;ÚcodeoprrÚ__all__rrrr ÚargparseÚArgumentParserÚparserÚ add_argumentÚ parse_argsr%ÚqÚflagsÚquietr_rLrrÚr|s¬ðñó Ûß3ò €÷YñYôxpÐ/ôpóh&ð4 ˆzÒÛà $ˆX× $Ñ $Ó &€FØ ×ј \ØHðôJà × Ñ Ó €DØ ‡v‚v�—‘—’؉àˆÙ ˆVÕðr