"TeYs!XddlmZddlZddlZddlZddlZddlmZmZddl m Z ddl m Z m Z ddlmZmZmZmZmZmZmZmZmZmZddlmZddlmZmZmZmZm Z m!Z!dd lm"Z#dd lm$Z$dd l%m&Z&d d l'm(Z(d dl)m*Z*d dl+m,Z,d dl-m.Z.m/Z/m0Z0m1Z1m2Z2d dl3m4Z4d dl5m6Z6m7Z7d dl8m9Z9d dl:m;Z;d dlm?Z?d d l@m"Z"d dlAmBZBejdk(ZDdZEdZFddddddeEeFdddddd d!ee.d"eeGd#eGd$eeHd%eId&eId'eGd(eGd)eId*eeId+eId,eeeHe fd-eGd.eeeJeJee geffd/ZKeGd0d1ZLeGd2d3ZMeGd4d5ZNeGd6d7ZOGd8d9e6ZPGd:d;ZQeRded.dfd?ZSd>ed.dfd@ZTdBdAZUeUyy)C)absolute_importN) dataclassfield)walk_tb) ModuleType TracebackType) AnyCallableDictIterableListOptionalSequenceTupleTypeUnion)guess_lexer_for_filename)CommentKeywordNameNumberOperatorString)Text)Token) ClassNotFound)pretty) loop_last)Columns)ConsoleConsoleOptionsConsoleRenderable RenderResultgroup) Constrain)RegexHighlighterReprHighlighter)Panel) render_scope)Style)Syntax)ThemeWindows PdFT) consolewidth extra_linestheme word_wrap show_localslocals_max_lengthlocals_max_stringlocals_hide_dunderlocals_hide_sunder indent_guidessuppress max_framesr4r5r6r7r8r9r:r;r<r=r>r?r@returnc  | tdn|jr dn dttdtdtt ddf    f d d t ddffd } t}| |tjS#t$r tj}t_ |cYSwxYw) a"Install a rich traceback handler. Once installed, any tracebacks will be printed with syntax highlighting and rich formatting. Args: console (Optional[Console], optional): Console to write exception to. Default uses internal Console instance. width (Optional[int], optional): Width (in characters) of traceback. Defaults to 100. extra_lines (int, optional): Extra lines of code. Defaults to 3. theme (Optional[str], optional): Pygments theme to use in traceback. Defaults to ``None`` which will pick a theme appropriate for the platform. word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False. show_locals (bool, optional): Enable display of local variables. Defaults to False. locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation. Defaults to 10. locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80. locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True. locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False. indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True. suppress (Sequence[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback. Returns: Callable: The previous exception handler that was replaced. NT)stderrtype_value tracebackrAc~ jtj|||  t y)N r5r6r7r8r9r:r;r<r=r>r?r@)print Tracebackfrom_exceptionbool)rDrErFr6r>r<r=r:r;r@r9r?r7traceback_consoler5r8s 0/usr/lib/python3/dist-packages/rich/traceback.py excepthookzinstall..excepthookasY   $ $'#'"3"3#5#'(:#;+!% %  ipc ijdtdtddffd }dddtdtdtddffd_|_fd _y) NargskwargsrAc||i|y)zEwrap the default ip.showtraceback to store info for ip._showtracebackNr3)rSrTdefault_showtracebacktb_datas rNipy_show_tracebackzCinstall..ipy_excepthook_closure..ipy_show_traceback~sG !4 26 2rPF) is_syntaxrYc j}|rdn|d} jdd} jd|rdnd}t|D]}|n|j}|d|d|i y)z2Internally called traceback from ip._showtracebackNrunning_compiled_codeF tb_offsetrr) _get_exc_infogetrangetb_next) rYrSrT exc_tupletbcompiledr]_rOrQrWs rNipy_display_tracebackzFinstall..ipy_excepthook_closure..ipy_display_tracebacks ((*I3<$1B{{#:EBH KhAFI9% :ZZ y|Yq\2 6GrPc|ddi|S)NrYTr3)rSrTrfs rNz9install..ipy_excepthook_closure..s 5J 6 !6 %+6 rP) showtracebackr rL_showtracebackshowsyntaxerror)rQrXrVrfrWrOs` @@@rNipy_excepthook_closurez'install..ipy_excepthook_closurezst " 0 0 3c 3S 3T 3+0  #' ;>   02- rP) r! is_jupyterr BaseExceptionrrr get_ipythonsysrO Exception)r4r5r6r7r8r9r:r;r<r=r>r?r@rlrQold_excepthookrOrMs ```````````` @@rNinstallrs0sR18t,W  ( (-?-G   M"  M*      2' 3' 4' R  ]r"~~ # s4!B&B?>B?cleZdZUeed<eed<eed<dZeed<dZee ee jfed<y)FramefilenamelinenonamelineNlocals) __name__ __module__ __qualname__str__annotations__intrzr{rr rNoder3rPrNrurus7M K ID#N/3FHT#v{{*+ ,3rPruc@eZdZUeed<eed<eed<eed<eed<y) _SyntaxErroroffsetrvrzrwmsgN)r|r}r~rrrr3rPrNrrs KM I K HrPrcfeZdZUeed<eed<dZeeed<dZe ed<e e Z e eed<y) Stackexc_type exc_valueN syntax_errorFis_cause)default_factoryframes)r|r}r~rrrrrrrLrlistrr rur3rPrNrrs8MN+/L(<(/Hd5FDK5rPrceZdZUeeed<y)TracestacksN)r|r}r~r rrr3rPrNrrs KrPrceZdZdgZy)PathHighlighterz(?P.*/)(?P.+)N)r|r}r~ highlightsr3rPrNrrs -.JrPrc"eZdZdZddddddZ d-dd dd d eed d d d dd deedee de dee de de de de de de de de e e efde fdZedd dd d eed d d d dd deededeedee de dee de de de de de de de de e e efde ddf d Zed eed d d!deededeede de de de de defd"Zd#ed$edefd%Zed&edefd'Zed(e d)e de fd*Zed+edefd,Z y).rJaA Console renderable that renders a traceback. Args: trace (Trace, optional): A `Trace` object produced from `extract`. Defaults to None, which uses the last exception. width (Optional[int], optional): Number of characters used to traceback. Defaults to 100. extra_lines (int, optional): Additional lines of code to render. Defaults to 3. theme (str, optional): Override pygments theme used in traceback. word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False. show_locals (bool, optional): Enable display of local variables. Defaults to False. indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True. locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation. Defaults to 10. locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80. locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True. locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False. suppress (Sequence[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback. max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100. textpythoncythonpyrex)ryz.pyz.pxdz.pyxz.pxiNr1r2FTr3rHtracer5r6r7r8r9r:r;r<r=r>r?r@c |>tj\}}}||| td|j||||}||_||_||_tj|xsd|_ ||_ ||_ | |_ ||_ ||_| |_| |_g|_| D]}t%|t&s@|j( J|dt*j,j/|j(}n|}t*j,j1t*j,j3|}|j"j5|| dkDrt7d| |_yd|_y)Nz9Value for 'trace' required if not called in except: blockr9 ansi_darkz+ must be a module with '__file__' attributer)rpexc_info ValueErrorextractrr5r6r, get_themer7r8r9r>r:r;r<r=r? isinstancer__file__ospathdirnamenormpathabspathappendmaxr@)selfrr5r6r7r8r9r:r;r<r=r>r?r@rrrFsuppress_entityrs rN__init__zTraceback.__init__sr" =-0\\^ *Hi9#4 8I OLL)YK!E  &%%e&:{; "&*!2!2"4"4') ' 'Oos3#,,8U%((STU8ww'?'?@&77##BGGOOD$9:D MM  & '1;Q#a,ArPrrrFrAc ^|j||||| | | | }|||||||| | | | | || S)aeCreate a traceback from exception info Args: exc_type (Type[BaseException]): Exception type. exc_value (BaseException): Exception value. traceback (TracebackType): Python Traceback object. width (Optional[int], optional): Number of characters used to traceback. Defaults to 100. extra_lines (int, optional): Additional lines of code to render. Defaults to 3. theme (str, optional): Override pygments theme used in traceback. word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False. show_locals (bool, optional): Enable display of local variables. Defaults to False. indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True. locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation. Defaults to 10. locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80. locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True. locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False. suppress (Iterable[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback. max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100. Returns: Traceback: A Traceback instance that may be printed. r9r:r;r<r=) r5r6r7r8r9r>r:r;r<r=r?r@)r)clsrrrFr5r6r7r8r9r:r;r<r=r>r?r@rich_tracebacks rNrKzTraceback.from_exception$sfV   #//11%   ##'//11!  rPrcg} d} ddlm} dtdtfd} t | |j | || } t |trWt|jxsd|jxsd |jxsd|jxsd |j | _| j| | j j}d t"t$tt&fdt"t$tt&fffd }t)|D]3\}}|j*j,}|rP|j/ds?t0j2j5|s t0j2j7| |}|j8j;ddrt=|xsd ||j*j>|rJ||j8jADcic]\}}|tCjD||| c}}nd}|||j8j;dds%| j dd=6tG|dd}|r|jH}|}|jJ}d} ]|jL}|r+tG|dds|jH}|}|jJ}d}  tO| }|Scc}}w)aExtract traceback information. Args: exc_type (Type[BaseException]): Exception type. exc_value (BaseException): Exception value. traceback (TracebackType): Python Traceback object. show_locals (bool, optional): Enable display of local variables. Defaults to False. locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation. Defaults to 10. locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80. locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True. locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False. Returns: Trace: A Trace instance which you can use to construct a `Traceback`. Fr) _IMPORT_CWD_objectrAc8 t|S#t$rYywxYw)z1Don't allow exceptions from __str__ to propagate.z)rrq)rs rNsafe_strz#Traceback.extract..safe_strs# 27|# 21 2s T)rrr?ry)rrvrwrzr iter_localsc3Ks s |Ed{y|D]3\}}r|jdrr|jdr.||f5y7>w)z-Extract locals from an iterator of key pairs.N__re startswith)rkeyrEr<r=s rN get_localsz%Traceback.extract..get_localss_+.@***"-%JC)cnnT.B )cnnS.A u*$ %+s AA ?A<_rich_traceback_omit) max_length max_stringN)rvrwrxr{_rich_traceback_guard __cause____suppress_context__)r)(richrr rrr|r SyntaxErrorrrrvrwrrrrrr robjectrf_code co_filenamerrrisabsjoinf_localsr_ruco_nameitemsrtraversegetattr __class__ __traceback__ __context__r)rrrrFr9r:r;r<r=rrrrstackrr frame_summaryline_norvrrEframecausers `` rNrzTraceback.extractjs<!$ 2c 2c 2!("3"34"9-!E )[1%1$++0q&//63$++0q"-2! &" MM% \\((F %%eCK&89 %%V ,- %+2)*< (& w(//;;H$7$7$<77==2#%77<< X#F ))--.DeL%_"&--55#+5]5K5K5Q5Q5S*T  'C V__!'8'8u  ))--.EuM Q3 (6I{D9E ??! "// ))EWY0FN ??! !//   V$ Is'#Kr4optionsc #K|j}|j}|j}tid|td|t d|t d|tjd|td|ttdzd |t d |ttd zd |td |tjd|tjd|tjd|t jd|td|td|tjtdzd}t!}t#t%|j&j(D]\}} | j*rTt-|j/| d|ddd} t1| |j2} |j5|5| ddd| j6|j5|5t1t-|j9| j6|ddd|j2|j2dddt;j<| j>ddf|| j6j@nh| jBr8t;j<| j>ddf|| jBn$t;j<| j>df|r| jDrt;jFdt;jFdy#1swYhxYw#1swYxYww) Nr pygments.textpygments.stringpygments.functionpygments.numberz repr.indentT)dimzrepr.strz repr.brace)boldz repr.numberzrepr.bool_truezrepr.bool_falsez repr.nonez scope.borderz scope.equalsz scope.keyzscope.key.specialF)inheritz7[traceback.title]Traceback [dim](most recent call last)ztraceback.border)rr)titlestyle border_styleexpandpaddingztraceback.border.syntax_error)rrrrr5z: ztraceback.exc_typezI [i]The above exception was the direct cause of the following exception: zH [i]During handling of the above exception, another exception occurred: )$r7get_background_styleget_style_for_tokenr- TextTokenrrrFunctionrrr+rConstant Delimiterrr(rreversedrrrr) _render_stackr&r5 use_themer_render_syntax_errorrassemblerrrr from_markup) rr4rr7background_style token_styletraceback_theme highlighterlastrstack_renderables rN__rich_console__zTraceback.__rich_console__se  557//  +i0 U!3 ";v#6 $[%?   ";v#6   {73eoE  K/ k)4u$7GG {62 !+g.>.>"? ";w/?/?#@ [)9)9:  F,<,< =  H 5 [.  $[%?%D/%Q! $' ,&' $Xdjj.?.?%@A. KD%||6;&&u-S*!3" 7 $--=tzz#J &&7+**+!!-&&7 # 55e6H6HI"2)H#'$*"&**     mm'r*,@A 2 2 6 67mm'r*,@A0 mm'7:N$OPP>>**e**dY. ++  s?G5M<7M"<%M<!A M/,B4M<"AM<"M, 'M</M9 4M<rc#8Kt}t}|jdk7rptjj |jrGt jd|jdfdt|jdfd}||||jj}d|_ t|jd z t|}|j!d |||t j"d d|zzd zdz }|yw) Nz r:rrrrTrzbold underline u[traceback.offset]▲[/])r(rrvrrexistsrrrrwrzrstripno_wrapminrlenstylizer)rrrpath_highlighterrsyntax_error_textrs rNrzTraceback._render_syntax_error5s%' *,  I -ww~~l334}}../02CD*,,-/@A)  't,,' (9(9(@(@(BC$(!\((1,c2C.DE!!"2FFCT-- 3< "< <!   sDDrvcodecRtjj|d}|sA|jd}|dk7r|d|n|}|j drd|j vry |j j|xst||jS#t$rYywxYw)Nrz#!rr) rrsplitextindexrlowerLEXERSr_rrxr)rrvr extnew_line_index first_lines rN _guess_lexerzTraceback._guess_lexerLsggx(,"ZZ-N2@B2Fo~.DJ$$T*x:;K;K;M/M ::>>#&W*B8T*R*W*W W  s'2B B&%B&rc #4Kt}j}dtdtfd}dtdtt ffd }d}j dk7r.read_codeas779--h78 8rPrc3K|jr;t|jdjjjyyw)Nr{)rr>rr)r{r*r>r:r;)rrs rN render_localsz.Traceback._render_stack..render_localslsE||"LL""&"4"4#55#55 sA A rr[FTz ... z frames hidden ...centerztraceback.error)justifyrc3@K|]}j|ywNr).0rframe_filenames rN z*Traceback._render_stack..sW^66t<Wsrrrrz in rrzin rryX)r7 line_numbers line_rangehighlight_linesr8 code_widthr>dedentr)rr)rr7rrur r#r@r`rr enumeraterrvanyr?rrrrrwrxrrr,r6r8r>r{r rq)rrr r7rrexclude_framesexcluded frame_indexrfirst suppressedrr  lexer_namesyntaxerrorr"s` @rNrzTraceback._render_stack\s *,  9 9 9  84E+F +/ ??a "1$ELL!DOOq$88N "+ELL"9P  K+"?%111S011CD$+ !1$E"^^NWWWJww~~enn-}}$T%..@Q%RS*&(9:ZZ!45) }}ZZ!45*&(9:) >>,,S1%J~~((-(///&$U^^4D!!%!2!25>>4!HJ#"#%)!LL4+;+;;!LL4+;+;;$*/"&..#%&*&8&8$FH!<< &!.u!5%& $ MP N04!--eW'89sIHLK#LK%3L5BK%9+L% L.L LLLr )!r|r}r~__doc__rLOCALS_MAX_LENGTHLOCALS_MAX_STRINGrrrrrLr rrr classmethodrr rnrrKrr!r"r$rr%rrrrrr3rPrNrJrJs2,  F"&1F ##!!2!2#'#("571F1F} 1F  1F } 1F1F1F1F1F!1F!1F1F5j121F1Ff ##!!2!2#'#("57#C s)C !C M* C } C C }C C C C C !C !C C 5j12!C "#C $ %C C J"!2!2#'#(z}%z!zM* z  zzz!z!z zzxLL)7L L\ W  ,   , C s s   Wq5q\q qrPrJ__main__)r!ac$d}t||z y)Nr)rI)r9ones rNbarr<s cAgrPc,d}hddd}t|y)NT> Duncan Idaho Thufir Hawat Paul AtreidesVladimir Harkonnen)NFT) characters atomic_types)r<)r9rzeds rNfoorEs" $ 0  ArPcr tdy#tYyxYw#tjdYyxYw)NrTr)rE slfkjsldkfjr4print_exceptionr3rPrNr3r3s4 6 A  6  # # # 5s 6)rAN)V __future__rrrplatformrp dataclassesrrrFrtypesrrtypingr r r r r rrrrrpygments.lexersrpygments.tokenrrrrrrrrr pygments.utilrryr_looprcolumnsr r4r!r"r#r$r% constrainr&rr'r(panelr)scoper*rr+r2r,rr7r-systemWINDOWSr5r6rrrLrnrsrurrrrrJr|r<rEr3r3rPrNrXsU&  (+   5KK, 'TT : (// y ( "&..#)-13| g | C=| | C= |  |||||!||uS*_-.||tM"M8M3JKSPQ|~ 44 4      66 6  /&/{{| z iGst s t 6 GArP