"Te UddlZddlZddlZddlZddlZddlZddlmZmZddl m Z m Z ddl m Z ddl mZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZmZmZdd lmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,ddl-m.Z.ej^dk\r ddlm0Z0m1Z1m2Z2n ddl3m0Z0m1Z1m2Z2ddl4m5Z5m6Z6ddl7m7Z7ddl8m9Z9m:Z:ddl;mZ>m?Z?ddl@mAZAmBZBddlCmDZDmEZEddlFmGZGddlHmIZIddlJmKZKmLZLddlMmNZOddlPmQZQmRZRddlSmTZTmUZUddlVmWZWmXZXdd lYmZZZdd!l[m\Z\dd"l]m^Z^dd#l_m`Z`dd$lambZbdd%lcmdZdmeZedd&lfmgZgdd'lhmiZimjZjmkZkdd(llmmZmmnZndd)lompZpmqZqerdd*lrmsZsdd+ltmuZudd,lvmwZwd-Zxd.Zyejd/k(Z{e!e+e|d0fgd0fZ}e0d1Z~e0d2ZGd3d4ZeZ ejjZ ej jZ ejjZeeefZeefZeDjeDjeDjd6ZGd7d8e&Ze Gd9d:Ze2Gd;de1Ze+eee|fZ e#e+eebfZeKZGd?d@eZGdAdBZGdCdDZGdEdFZGdGdHZGdIdJZGdKdLZGdMdNZddPedQe!dRe!dRefffdSZdQefdTZeDjeDjeDjBeDjdUZejGDcic]\}}|| c}}Ze GdVdWejJZGdXdYeZdae'dZed[<dd\ZdQefd]ZGd^d_Zd`e|dQe|fdaZedbk(rvedOcZejadddedfdOdgddhdidjdkdldmdnejadodpeeejedgdOdqgdrdsdtdudgdvgdwdxdtdygdzd{dtd|d}d~yy#e$rdZYQwxYw#e$rdZYBwxYw#e$rd5ZY3wxYwcc}}w)N)ABCabstractmethod) dataclassfield)datetime)wraps)getpass)escape)isclass)islice)ceil) monotonic) FrameType ModuleType TracebackType)IO TYPE_CHECKINGAnyCallableDictIterableListMapping NamedTupleOptionalTextIOTupleTypeUnioncast) NULL_FILE))LiteralProtocolruntime_checkable)errorsthemes)_emoji_replace)CONSOLE_HTML_FORMATCONSOLE_SVG_FORMAT) get_fileno)FormatTimeCallable LogRender)Align AlignMethod) ColorSystem blend_rgb)Control) EmojiVariant)NullHighlighterReprHighlighterrender) Measurementmeasure_renderables)Pager SystemPager)Pretty is_expandable) rich_cast)Region) render_scope)Screen)Segment)Style StyleType)Styled)DEFAULT_TERMINAL_THEMESVG_EXPORT_THEME TerminalTheme)TextTextType)Theme ThemeStack)WindowsConsoleFeatures)LiveStatussdWindowsrK)defaultleftcenterrightfull)foldcropellipsisignorec eZdZy)NoChangeN)__name__ __module__ __qualname__./usr/lib/python3/dist-packages/rich/console.pyr`r`Vsrer`)kitty256color16colorc(eZdZUdZeed< eed<y)ConsoleDimensionszSize of the terminal.widthheightN)rarbrc__doc__int__annotations__rdrerfrlrlts J. K-rerlceZdZUdZeed< eed< eed< eed< eed< eed< eed< d Z e e ed < d Z e e ed < d Ze eed < d Ze eed< d Ze eed< d Ze eed<edefdZddZeeeeeeeeed deeefdeeefdeeefd ee e efd ee e efd ee eefdee eefdee eefdee eefddfdZdeddfdZdeddfdZddZdededdfdZy )ConsoleOptionsz$Options for __rich_console__ method.sizelegacy_windows min_width max_width is_terminalencoding max_heightNjustifyoverflowFno_wrap highlightmarkuprnreturnc:|jjd S)z+Check if renderables should use ascii only.utf)ry startswithselfs rf ascii_onlyzConsoleOptions.ascii_onlys==++E222recvtjt}|jj|_|S)zdReturn a copy of the options. Returns: ConsoleOptions: a copy of self. )rs__new____dict__copyroptionss rfrzConsoleOptions.copys. #1"8"8"H==--/re) rmrvrwr{r|r}r~rrnrmc |j} t|tstd|x| _| _t|ts|| _t|ts|| _t|ts|| _t|ts|| _t|ts|| _t|ts|| _ t|ts|| _ t| ts| | | _ | dn td| | _ | S)zUpdate values, return a copy.rN) r isinstancer`maxrvrwr{r|r}r~rrzrn) rrmrvrwr{r|r}r~rrnrs rfupdatezConsoleOptions.updates))+%*475M AG  1)X. )G )X. )G '8,%GO(H-'G '8,%GO)X. )G &(+#GN&(+!%+"%+^TQGNrecV|j}td|x|_|_|S)zUpdate just the width, return a copy. Args: width (int): New width (sets both min_width and max_width) Returns: ~ConsoleOptions: New console options instance. r)rrrvrw)rrmrs rf update_widthzConsoleOptions.update_widths*))+03Au =G-recB|j}|x|_|_|S)zUpdate the height, and return a copy. Args: height (int): New height Returns: ~ConsoleOptions: New Console options instance. )rrzrn)rrnrs rf update_heightzConsoleOptions.update_heights#))+.44W^rec4|j}d|_|S)zReturn a copy of the options with height set to ``None``. Returns: ~ConsoleOptions: New console options instance. N)rrnrs rf reset_heightzConsoleOptions.reset_heights ))+recr|j}td|x|_|_|x|_|_|S)aUpdate the width and height, and return a copy. Args: width (int): New width (sets both min_width and max_width). height (int): New height. Returns: ~ConsoleOptions: New console options instance. r)rrrvrwrnrz)rrmrnrs rfupdate_dimensionsz ConsoleOptions.update_dimensionss9))+03Au =G-.44+re)rrs)rarbrcrorlrqboolrpstrr{r JustifyMethodr|OverflowMethodr}r~rrnpropertyrr NO_CHANGErr`rrrrrrdrerfrsrs}s. 2N&N&<MO2'+GXm $+0)-Hh~&-1#GXd^#$ $Ix~$,!FHTN!/ FHSM  3D33'0*3*3G3<5>2;1:#S(]##h' # h' # x .89 #0(:;#x~x/0#$12#htnh./#hsmX-.# #J # *:  C ,<  s C  33D9 ==T-- LL $ $U + rerrrc|jrD|jjd|jr|jj dyyy)NFT)rrrrrrs rfrzScreenContext.__exit__sB == LL ' ' . ((.  rer)rr)rarbrcrorrFrRenderableTyperrrrrrrrdrerfrrssIK /3.decorator.._replaces" $1&1K+/3/ /re)rrr)rrr s` rf decoratorzgroup..decorators7 v 0C 03 05 0  0re)rrr r)r rs` rfgrouprs8 h~667  #u*   rec tt}|jj}dt |jvst j ds|dk(ry|dk(ryy#t$rYywxYw)z-Check if we're running in a Jupyter notebook.Fz google.colabDATABRICKS_RUNTIME_VERSIONZMQInteractiveShellTTerminalInteractiveShell) get_ipython NameError __class__rarosgetenv)ipythonshells rf _is_jupyterr)ssmG    & &E#g//00 991 2 ) ) , , sA!! A-,A-)standard256 truecolorwindowscLeZdZUdZeed<eeZe e ed<dZ e ed<y)ConsoleThreadLocalsz(Thread local values for Console context. theme_stack)default_factoryrr buffer_indexN) rarbrcrorNrqrrrrrDr2rprdrerfr/r/$s(2!$7FDM7L#rer/c6eZdZdZedeedeefdZy) RenderHookz(Provides hooks in to the render process.rrcy)aLCalled with a list of objects to render. This method can return a new list of renderables, or modify and return the same list. Args: renderables (List[ConsoleRenderable]): A number of renderable objects. Returns: List[ConsoleRenderable]: A replacement list of renderables. Nrd)rrs rfprocess_renderableszRenderHook.process_renderables0sreN)rarbrcrorrrr6rdrerfr4r4-s32   12       rer4rO_windows_console_featuresc@ttSddlm}|atS)Nr'get_windows_console_features)r7_windowsr:r9s rfr:r:Cs  ,((6 < > $$rec<txrtj S)zDetect legacy Windows.)WINDOWSr:vtrdrerfdetect_legacy_windowsr?Ms  <79<<<Z.dd?Z/d(efd@Z0ddAdedBe d(dfdCZ1ddDZ2ddAdedBe d(e3fdEZ4ed(e efdFZ5ed(efdGZ6ed(e fdHZ7ed(e fdIZ8ed(e9fdJZ:ed(e;fdKZe>j8ded(dfdOZ>ed(efdPZ?e?j8ded(dfdQZ?ddRZ@d(eAfdSZB ddTe eCdUe dVe d(eDfdWZEddYed(dfdZZFdd[e d(dfd\ZGd]d^d_d`dadbeHdceddedeedfed(dgf dhZIddie d(e fdjZJddke d(e fdlZKed(e fdmZLdned(e fdoZM ddpe de ed(dqfdrZNddsdteHdue e9d(eOfdvZP ddteHdue e9d(eQefdwZR dddddxdteHdue e9de eSdye dze d(eeef d{ZTd|ddddddd}d~edeeeSfde eUde eVde e de e de e d!e eWd(dfdZXdddeeeSfde eeSefd(eSfdZYddddddeQe-dedede eUde e de e de e d(eeZfdZ[ ddddddne\dedeeeSfde]d(df dZ^de_d(dfdZ`dddddde-dedede eeeSfde e d(df dZadddddddddddddddde-dedede eeeSfde eUde eVde e de e de e de e de ede ede de e de d(df dZb ddddddddddd de ede-dedeefde de de de de de ee-ge-fde d(dfdZcddddteHde eddue e9d(dfdZe ddeeededed(dfdZfddddddddde edede ede de deQeeegfded(dfdZheiejjfdedege elfd(e=eeemee-fffdZndddddddddXd de-dedede eeeSfde eUde e de e de e de ded(dfdZoddZpdeQed(efdÄZq ddddddĜde\de de de de erd(ef dȄZsdddɜde dUe d(efd˄Ztdddɜdede dUe d(dfd̈́ZudddddΜde evde de ede d(ef dфZwddexddΜdede evde dede d(df d҄Zydddezddd՜dnede evde dedede ed(efd؄Z{dddezddd՜dednede evde dedede ed(dfdلZ|y)rar A high level console interface. Args: color_system (str, optional): The color system supported by your terminal, either ``"standard"``, ``"256"`` or ``"truecolor"``. Leave as ``"auto"`` to autodetect. force_terminal (Optional[bool], optional): Enable/disable terminal control codes, or None to auto-detect terminal. Defaults to None. force_jupyter (Optional[bool], optional): Enable/disable Jupyter rendering, or None to auto-detect Jupyter. Defaults to None. force_interactive (Optional[bool], optional): Enable/disable interactive mode, or None to auto detect. Defaults to None. soft_wrap (Optional[bool], optional): Set soft wrap default on print method. Defaults to False. theme (Theme, optional): An optional style theme object, or ``None`` for default theme. stderr (bool, optional): Use stderr rather than stdout if ``file`` is not specified. Defaults to False. file (IO, optional): A file object where the console should write to. Defaults to stdout. quiet (bool, Optional): Boolean to suppress all output. Defaults to False. width (int, optional): The width of the terminal. Leave as default to auto-detect width. height (int, optional): The height of the terminal. Leave as default to auto-detect height. style (StyleType, optional): Style to apply to all output, or None for no style. Defaults to None. no_color (Optional[bool], optional): Enabled no color mode, or None to auto detect. Defaults to None. tab_size (int, optional): Number of spaces used to replace a tab character. Defaults to 8. record (bool, optional): Boolean to enable recording of terminal output, required to call :meth:`export_html`, :meth:`export_svg`, and :meth:`export_text`. Defaults to False. markup (bool, optional): Boolean to enable :ref:`console_markup`. Defaults to True. emoji (bool, optional): Enable emoji code. Defaults to True. emoji_variant (str, optional): Optional emoji variant, either "text" or "emoji". Defaults to None. highlight (bool, optional): Enable automatic highlighting. Defaults to True. log_time (bool, optional): Boolean to enable logging of time by :meth:`log` methods. Defaults to True. log_path (bool, optional): Boolean to enable the logging of the caller by :meth:`log`. Defaults to True. log_time_format (Union[str, TimeFormatterCallable], optional): If ``log_time`` is enabled, either string for strftime or callable that formats the time. Defaults to "[%X] ". highlighter (HighlighterType, optional): Default highlighter. legacy_windows (bool, optional): Enable legacy Windows mode, or ``None`` to auto detect. Defaults to ``None``. safe_box (bool, optional): Restrict box options that don't render on legacy Windows. get_datetime (Callable[[], datetime], optional): Callable that gets the current time as a datetime.datetime object (used by Console.log), or None for datetime.now. get_time (Callable[[], time], optional): Callable that gets the current time in seconds, default uses time.monotonic. _environautoNFr#Tz[%X]) color_systemforce_terminal force_jupyterforce_interactive soft_wraprstderrfilequietrmrnrno_colortab_sizerecordremoji emoji_variantr~log_timelog_pathlog_time_format highlighterrusafe_box get_datetimeget_timerArC)rBr*r+r,r-rDrErFrGrrHrIrJrmrnrrKrLrMrrNrOr~rPrQrRrSHighlighterTyperurTrUrVc|||_| tn||_|jr| ?|jjd}||j r t |} nt } | ?|jjd}||j r t |} nt} ||_||_ ||_ ||_ ||_ ||_ |txr|j n||_| E|jjd}|(|j rt ||jz } | 8|jjd} | | j r t | } ||_| |_| |_|d|_|||_||_| |_||_|d|_n)|dk(r|j1|_nt2||_t5j6|_t;||||_|xst>|_ ||_!|xstDjF|_$|xstJ|_&| |_'| | n d|jv|_(||jRxr|jT n||_+t5j6|_,t[t]|t^j`n||_1g|_2g|_3d|_4d |_5y) NJUPYTER_COLUMNS JUPYTER_LINESCOLUMNSLINESrB) show_time show_path time_formatNO_COLOR)r0F)6rAr) is_jupyterrisdigitrpJUPYTER_DEFAULT_COLUMNSJUPYTER_DEFAULT_LINESrLrM_markup_emoji_emoji_variant _highlightr?rurG_width_height_force_terminal_filerJrH _color_system_detect_color_system COLOR_SYSTEMS threadingRLockrr/ _log_render_null_highlighterrSrTrnowrUrrVrrKrxis_dumb_terminalis_interactive_record_buffer_lockr/rNr)DEFAULT_thread_locals_record_buffer _render_hooks_live_is_alt_screen)!rrCrDrErFrGrrHrIrJrmrnrrKrLrMrrNrOr~rPrQrRrSrurTrUrVrAjupyter_columns jupyter_linescolumnsrs! rfrzConsole.__init__xsF  $DM+8+@+-m ??}"&--"3"34E"F".?3J3J3L0E3E~ $ 1 1/ B  ,1F1F1H /F2F     6C#%# $ MM%%g.E U]]_U"   #  %#1D     !%D  V #!%!:!:!>N .0/1'+ #rerc<d|jd|jdS)Nz)rmrmrs rf__repr__zConsole.__repr__s"  Ad.@.@-C1EErec|jxs,|jrtjntj}t |d|}|t }|S)z Get the file object to write to.rich_proxied_file)rlrHsysstdoutgetattrr!)rrIs rfrIz Console.files@zzHDKKcjjSZZt0$7 <D renew_filec||_y)zSet a new file object.N)rl)rrs rfrIz Console.files  rec.|jjSzGet a thread local buffer.)ryrrs rfrzConsole._buffers"")))rec.|jjSrryr2rs rf _buffer_indexzConsole._buffer_index s""///revaluec&||j_yrr)rrs rfrzConsole._buffer_indexs+0(rec.|jjS)z!Get the thread local theme stack.)ryr0rs rf _theme_stackzConsole._theme_stacks""...rec|jrtjS|jr |jryt rR|j rtj St}|jrtjStjS|jjddjj}|dvrtjS|jjddjj}|jd\}}}tj|tj }|S)z"Detect color system from env vars.N COLORTERMr)r,24bitTERM-)rar2 TRUECOLORrxrur=rur:r, EIGHT_BITrArstriplower rpartition _TERM_COLORSSTANDARD)rwindows_console_features color_termterm _term_name_hyphencolorsrCs rfrnzConsole._detect_color_systems ??(( (4#8#8 """***'C'E $,55%% !**  **;;AACIIKJ33",,,==$$VR0668>>@D*.//#*> 'J'++FK4H4HIL rec.|xjdz c_y)z4Enter in to a buffer context, and buffer all output.r'N)rrs rfrzConsole._enter_buffer0s arecN|xjdzc_|jy)z5Leave buffer context, and render content if required.r'N)r _check_bufferrs rfrzConsole._exit_buffer4s a rec|j5|jtjd||_dddy#1swYyxYw)zSet Live instance. Used by Live context manager. Args: live (Live): Live instance using this Console. Raises: errors.LiveError: If this Console has a Live context currently active. Nz+Only one live display may be active at once)rr|r( LiveError)rlives rfset_livezConsole.set_live9sCZZ zz%&&'TUUDJ   s )?AcT|j5d|_dddy#1swYyxYw)zClear the Live instance.N)rr|rs rf clear_livezConsole.clear_liveGs% ZZ DJ   s'hookc||j5|jj|dddy#1swYyxYw)zpAdd a new render hook to the stack. Args: hook (RenderHook): Render hook instance. N)rr{append)rrs rfpush_render_hookzConsole.push_render_hookLs4 ZZ ,    % %d + , , ,s2;cz|j5|jjdddy#1swYyxYw)z'Pop the last renderhook from the stack.N)rr{poprs rfpop_render_hookzConsole.pop_render_hookUs0 ZZ %    " " $ % % %s1:c&|j|S)z,Own context manager to enter buffer context.rrs rfrzConsole.__enter__Zs  rer exc_value tracebackc$|jy)zExit buffer context.N)r)rrrrs rfrzConsole.__exit___s rec$|jy)z`Begin capturing console output. Call :meth:`end_capture` to exit capture mode and return output.Nrrs rfrzConsole.begin_capturecs recz|j|j}|jdd=|j|S)zhEnd capture mode and return captured string. Returns: str: Console output. N)rrr)r render_results rfrzConsole.end_capturegs5 ++DLL9 LLO rerrc>|jj||y)aPush a new theme on to the top of the stack, replacing the styles from the previous theme. Generally speaking, you should call :meth:`~rich.console.Console.use_theme` to get a context manager, rather than calling this method directly. Args: theme (Theme): A theme instance. inherit (bool, optional): Inherit existing styles. Defaults to True. rN)rrrrrs rfrzConsole.push_themers $$UG$=B>c~|jjdd}|jdv}|jxr|S)zxDetect dumb terminal. Returns: bool: True if writing to a dumb terminal, otherwise False. rr)dumbunknown)rArrrx)r_termis_dumbs rfruzConsole.is_dumb_terminals< !!&"-++-#66+G+rec t|jj|j|jd|j|j |j S)zGet default console options.r')rzrtrurvrwryrx)rsrtrnrurmryrxrs rfrzConsole.optionssHyy''..jj]]((  recH|j9|j-t|j|jz |jS|jr tddSd}d}t r t j\}}n%tD]} t j|\}}n|jjd}||jr t|}|jjd}||jr t|}|xsd}|xsd}t|j||jz n |j|j|S|jS#tttf$rYwxYw#tttf$rYwxYw)zGet the size of the console. Returns: ConsoleDimensions: A named tuple containing the dimensions. NPr[r\)rirjrlrurur=r%get_terminal_sizeAttributeErrorrOSError _STD_STREAMSrArrbrp)rrmrnfile_descriptorrrs rfrtz Console.sizes ;; "t||'?$T[[43F3F%F U U  $R, ,# $   " 4 4 6 v$0 $&$8$8$IME6  --##I.  7??#4LE !!'*  ZF 2 +/;;+>ED'' 'DKKll*F  04   +#J8   ' G<s$)E/ F /FF F! F!new_sizec*|\}}||_||_y)zvSet a new size for the terminal. Args: new_size (Tuple[int, int]): New width and height. N)rirj)rrrmrns rfrtz Console.sizes! v  rec.|jjS)zsGet the width of the console. Returns: int: The width (in characters) of the console. )rtrmrs rfrmz Console.widthsyyrec||_y)zFSet width. Args: width (int): New width. N)ri)rrms rfrmz Console.width"s  rec.|jjS)zpGet the height of the console. Returns: int: The height (in lines) of the console. )rtrnrs rfrnzConsole.height+syyrec||_y)zISet height. Args: height (int): new height. N)rj)rrns rfrnzConsole.height4s  recJ|jtjy)z3Play a 'bell' sound (if supported by the terminal).N)controlr4bellrs rfrz Console.bell=s W\\^$rect|}|S)aA context manager to *capture* the result of print() or log() in a string, rather than writing it to the console. Example: >>> from rich.console import Console >>> console = Console() >>> with console.capture() as capture: ... console.print("[bold magenta]Hello World[/]") >>> print(capture.get()) Returns: Capture: Context manager with disables writing to the terminal. )r)rcaptures rfrzConsole.captureAs$-rerrrc t||||S)aA context manager to display anything printed within a "pager". The pager application is defined by the system and will typically support at least pressing a key to scroll. Args: pager (Pager, optional): A pager object, or None to use :class:`~rich.pager.SystemPager`. Defaults to None. styles (bool, optional): Show styles in pager. Defaults to False. links (bool, optional): Show links in pager. Defaults to False. Example: >>> from rich.console import Console >>> from rich.__main__ import make_test_card >>> console = Console() >>> with console.pager(): console.print(make_test_card()) Returns: PagerContext: A context manager. )rrr)r)rrrrs rfrz Console.pagerRs*DfEJJrer'rcP|dk\sJd|jt|y)zqWrite new line(s). Args: count (int, optional): Number of new lines. Defaults to 1. rzcount must be >= 0N)rrrs rfrz Console.lineis&z///z 75>"rehomec|r7|jtjtjy|jtjy)zClear the screen. Args: home (bool, optional): Also move the cursor to 'home' position. Defaults to True. N)rr4clearr)rrs rfrz Console.clearss3  LL',,. 9 LL )redotszstatus.spinnerg?g)@)spinner spinner_stylespeedrefresh_per_secondstatusrrrrrRc.ddlm}|||||||}|S)atDisplay a status and spinner. Args: status (RenderableType): A status renderable (str or Text typically). spinner (str, optional): Name of spinner animation (see python -m rich.spinner). Defaults to "dots". spinner_style (StyleType, optional): Style of spinner. Defaults to "status.spinner". speed (float, optional): Speed factor for spinner animation. Defaults to 1.0. refresh_per_second (float, optional): Number of refreshes per second. Defaults to 12.5. Returns: Status: A Status object that may be used as a context manager. r'rQ)rrrrr)rrR)rrrrrrrRstatus_renderables rfrzConsole.status~s,* #" '1  ! rercf|jr%|jtj|yy)zqShow or hide the cursor. Args: show (bool, optional): Set visibility of the cursor. TF)rxrr4r)rrs rfrzConsole.show_cursors*    LL,,T2 3reenablecd}|jr9|js-|jtj|d}||_|S)aEnables alternative screen mode. Note, if you enable this mode, you should ensure that is disabled before the application exits. See :meth:`~rich.Console.screen` for a context manager that handles this for you. Args: enable (bool, optional): Enable (True) or disable (False) alternate screen. Defaults to True. Returns: bool: True if the control codes were written. FT)rxrurr4 alt_screenr})rrchangeds rfrzConsole.set_alt_screensC   D$7$7 LL++F3 4G"(D rec|jS)zCheck if the alt screen was enabled. Returns: bool: True if the alt screen was enabled, otherwise False. )r}rs rf is_alt_screenzConsole.is_alt_screens"""retitlecf|jr%|jtj|yy)aSet the title of the console terminal window. Warning: There is no means within Rich of "resetting" the window title to its previous value, meaning the title you set will persist even after your application exits. ``fish`` shell resets the window title before and after each command by default, negating this issue. Windows Terminal and command prompt will also reset the title for you. Most other shells and terminals, however, do not do this. Some terminals may require configuration changes before you can set the title. Some terminals may not support setting the title at all. Other software (including the terminal itself, the shell, custom prompts, plugins, etc.) may also set the terminal window title. This could result in whatever value you write using this method being overwritten. Args: title (str): The new title of the terminal window. Returns: bool: True if the control code to change the terminal title was written, otherwise False. Note that a return value of True does not guarantee that the window title has actually changed, since the feature may be unsupported/disabled in some terminals. TF)rxrr4r)rrs rfset_window_titlezConsole.set_window_titles(6    LLu- .rerrc&t|||xsdS)auContext manager to enable and disable 'alternative screen' mode. Args: hide_cursor (bool, optional): Also hide the cursor. Defaults to False. style (Style, optional): Optional style for screen. Defaults to None. Returns: ~ScreenContext: Context which enables alternate screen on enter, and disables it on exit. r)rr)r)rrrs rfrzConsole.screensT{%+2NNrerrrcPtj||xs |j|}|S)aMeasure a renderable. Returns a :class:`~rich.measure.Measurement` object which contains information regarding the number of characters required to print the renderable. Args: renderable (RenderableType): Any renderable or string. options (Optional[ConsoleOptions], optional): Options to use when measuring, or None to use default options. Defaults to None. Returns: Measurement: A measurement of the renderable. )r:rr)rrr measurements rfmeasurezConsole.measures%"oodG,Ct||ZP rec#vK|xs |j}|jdkryt|}t|drt |s|j ||}ndt |tr;|j||j|j}|j ||}ntjd|d t|}t}|j!}|D]-}t ||r||j#||Ed{/y#t$rtjd|dwxYw7-w) akRender an object in to an iterable of `Segment` instances. This method contains the logic for rendering objects with the console protocol. You are unlikely to need to use it directly, unless you are extending the library. Args: renderable (RenderableType): An object supporting the console protocol, or an object that may be converted to a string. options (ConsoleOptions, optional): An options object, or None to use self.options. Defaults to None. Returns: Iterable[Segment]: An iterable of segments that may be rendered. r'Nr)r~rzUnable to render zC; A str, Segment or object with __rich_console__ method is requiredzobject z is not renderable)rrwr@rr rrr render_strr~rr(NotRenderableErroriter TypeErrorrDrr9) rrr_optionsrender_iterabletext_renderable iter_render_Segment render_outputs rfr9zConsole.rendersP"*dll    ! z* :1 27:;N(99$IO  C ("ooh&8&8.O.>>tXNO++#J>2TT   /K ((*( @M-2##;;}h???  @  ++/,,>?  @s+B:D9= DAD9 D7 D9#D44D9)rpad new_linesrrc ^|j5|xs |j}|j||}|rtj||}|j }| t d|}tttj||j|||d|} |j r|j t| z } | dkDrU|r$td|jz|tdgntd|jz|gg} | j| | z| cdddS#1swYyxYw)aGRender objects in to a list of lines. The output of render_lines is useful when further formatting of rendered console text is required, such as the Panel class which draws a border around any renderable object. Args: renderable (RenderableType): Any object renderable in the console. options (Optional[ConsoleOptions], optional): Console options, or None to use self.options. Default to ``None``. style (Style, optional): Optional style to apply to renderables. Defaults to ``None``. pad (bool, optional): Pad lines shorter than render width. Defaults to ``True``. new_lines (bool, optional): Include " " characters at end of lines. Returns: List[List[Segment]]: A list of lines, where a line is a list of Segment objects. Nr)include_new_linesrrrr) rrr9rD apply_stylernrrr split_and_crop_linesrwrextend) rrrrrrrender_options _rendered render_heightr extra_linespad_lines rf render_lineszConsole.render_lines:s20ZZ! $4 N J?I#// 5A *11M( #A} 5 00!&00*3# !  E$$0,33c%j@ ?%!~'?'?!?GQUW%cN,D,D&DeLM H LLK!78C! ! ! s D D##D,r)rr{r|rNrr~rStextr{r|rKc|xs|duxr |j} |xs|duxr |j} |xs|duxr |j} | r(t||| |j} || _|| _n(t| rt||jn||||} | r|xs|jnd} | $| t| }|j| |S| S)aConvert a string to a Text instance. This is called automatically if you print or log a string. Args: text (str): Text to render. style (Union[str, Style], optional): Style to apply to rendered text. justify (str, optional): Justify method: "default", "left", "center", "full", or "right". Defaults to ``None``. overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to ``None``. emoji (Optional[bool], optional): Enable emoji, or ``None`` to use Console default. markup (Optional[bool], optional): Enable markup, or ``None`` to use Console default. highlight (Optional[bool], optional): Enable highlighting, or ``None`` to use Console default. highlighter (HighlighterType, optional): Optional highlighter to apply. Returns: ConsoleRenderable: Renderable object. N)rrNrO)default_variant)r{r|r) rfrerh render_markuprgr{r|rKr*rSr copy_styles)rrrr{r|rNrr~rS emoji_enabledmarkup_enabledhighlight_enabled rich_text _highlighterhighlight_texts rfrzConsole.render_strus8@%4-"?DKK DFdN$Ct||%P)t*;*O %#"11 I !(I !)I  tT5H5HI! I=N 7t'7'7SW  #)#i.9N  & &y 1! !re)rVnamerVcft|tr|S |jj|}|tj|}|j r|j S|S#tj$r9}||j|cYd}~Stjd|d|dd}~wwxYw)a Get a Style instance by its theme name or parse a definition. Args: name (str): The name of a style or a style definition. Returns: Style: A Style object. Raises: MissingStyle: If no style could be parsed from name. NzFailed to get style z; ) rrErrparselinkrr(StyleSyntaxError get_style MissingStyle)rr)rVrerrors rfr.zConsole.get_styles dE "K %%))$/E} D)#(::5::< 85 8&& "~~g..%%&thb8  s*A A$"A$$B07B+ B0B++B0r{rNrr~objectsseprc g}|jgj} dvrdtddffd } | t} |s||jr |j} d fd } |D]} t | } t | tr| |j| ||| :t | tr | | St | tr| | st| r| t| | | | t| | |j4|j|j}|D cgc]} t| |}} |Scc} w) aCombine a number of renderables and text into one renderable. Args: objects (Iterable[Any]): Anything that Rich can render. sep (str): String to write between print data. end (str): String to write at end of print data. justify (str, optional): One of "left", "right", "center", or "full". Defaults to ``None``. emoji (Optional[bool], optional): Enable emoji code, or ``None`` to use console default. markup (Optional[bool], optional): Enable markup, or ``None`` to use console default. highlight (Optional[bool], optional): Enable automatic highlighting, or ``None`` to use console default. Returns: List[ConsoleRenderable]: A list of things to render. )rWrXrYrrNc Ft|ttyr)r0r r1)r_appendr{s rf align_appendz2Console._collect_renderables..align_appendsj${G*DEFrecvr6t}|jjyy)N)r{r)rKjoinr)sep_textrrr{r3rs rf check_textz0Console._collect_renderables..check_texts3W#>x}}T*+ re)rNrrS)rSrN)rr rsrhrSr@rrrrKrr?r>rr.rG)rr2r3rr{rNrr~r append_textr7r'r;rrr6rrs ``` @@@rf_collect_renderableszConsole._collect_renderabless_202 $$kk  1 1 G GD G"F(9 *t++L   " ;J":.J*c*OO"%L$ J-J'J(9: z"z* vjlCDLZ9:# ;&  :: !NN4::.EGRS6*e4SKSTs E#u─z rule.linerX) charactersralignr?r@cJddlm}|||||}|j|y)uDraw a line with optional centered title. Args: title (str, optional): Text to render over the rule. Defaults to "". characters (str, optional): Character(s) to form the line. Defaults to "─". style (str, optional): Style of line. Defaults to "rule.line". align (str, optional): How to align the title, one of "left", "center", or "right". Defaults to "center". r')Rule)rr?rr@N)rulerBr)rrr?rr@rBrCs rfrCz Console.rules# %Je5Q 4rerc|js.|5|jjd|Ddddyy#1swYyxYw)zInsert non-printing control codes. Args: control_codes (str): Control codes, such as those that may move the cursor. c34K|]}|jywr)segment).0_controls rf z"Console.control..6s#MH$4$4#MN)rurr)rrs rfrzConsole.control.sL $$ N ###MW#MM N N% N Ns #<Arr)r3rrr~c h|jd|D}|j|||ddddd| y)aOutput to the terminal. This is a low-level way of writing to the terminal which unlike :meth:`~rich.console.Console.print` won't pretty print, wrap text, or apply markup, but will optionally apply highlighting and a basic style. Args: sep (str, optional): String to write between print data. Defaults to " ". end (str, optional): String to write at end of print data. Defaults to "\\n". style (Union[str, Style], optional): A style to apply to output. Defaults to None. highlight (Optional[bool], optional): Enable automatic highlighting, or ``None`` to use console default. Defaults to ``None``. c32K|]}t|ywr)r)rG_objects rfrIzConsole.out..Ks"GG3w<"GFTr^)rr~rNrr}r|r\rN)r9r)rr3rrr~r2 raw_outputs rfoutz Console.out8sD&(("Gw"GG    re)r3rrr{r|r}rNrr~rmrnr\rGnew_line_startr}r\rQc |s tf}| |j} | r |d}|d}d} |jdd}|5|j||||||| }|D]}|j |}|j j ||| t| |jnt| ||| }g}|j}|j}||D]}||||n9|D]4}|tj||||j|6|rVtdj!d|Dj#d kDr$|j%d tj&| rF|j(j}tj*||jd D] }|| n|j(j|dddy#1swYyxYw) a[Print to the console. Args: objects (positional args): Objects to log to the terminal. sep (str, optional): String to write between print data. Defaults to " ". end (str, optional): String to write at end of print data. Defaults to "\\n". style (Union[str, Style], optional): A style to apply to output. Defaults to None. justify (str, optional): Justify method: "default", "left", "right", "center", or "full". Defaults to ``None``. overflow (str, optional): Overflow method: "ignore", "crop", "fold", or "ellipsis". Defaults to None. no_wrap (Optional[bool], optional): Disable word wrapping. Defaults to None. emoji (Optional[bool], optional): Enable emoji code, or ``None`` to use console default. Defaults to ``None``. markup (Optional[bool], optional): Enable markup, or ``None`` to use console default. Defaults to ``None``. highlight (Optional[bool], optional): Enable automatic highlighting, or ``None`` to use console default. Defaults to ``None``. width (Optional[int], optional): Width of output, or ``None`` to auto-detect. Defaults to ``None``. crop (Optional[bool], optional): Crop output to width of terminal. Defaults to True. soft_wrap (bool, optional): Enable soft wrap mode which disables word wrapping and cropping of text or ``None`` for Console default. Defaults to ``None``. new_line_start (bool, False): Insert a new line at the start if the output contains more than one line. Defaults to ``False``. NTr^Fr1)r{r|rmrnr}rr~rc34K|]}|jywrrrGrFs rfrIz Console.print..sI IrJr'rr)rrGr{r>r6rrminrmrrr9rDrr.rr9 splitlinesinsertrrr)rr3rrr{r|r}rNrr~rmrnr\rGrQr2 render_hooksrrr new_segmentsrr9r buffer_extendrs rfrz Console.printXsJylG  I #D))!, 0 233#4K% D"66{C  D!\\00!050Ac%,y#1N+-L!((F[[F}"-?J6*n=>?#.J++":~>u@U ILIITTVW!''7<<>: $ 3 3 #88 $**%(D"$'(  ##L1a0 20 20 2s FGG!rg) dataindentr~ skip_keys ensure_asciicheck_circular allow_nanrV sort_keysjsonr]r^r_r`rarbrcc ddlm} || j|||||||| |  } n0t|tst d|d| |||||||| |  } |j | dy) aPretty prints JSON. Output will be valid JSON. Args: json (Optional[str]): A string containing JSON. data (Any): If json is not supplied, then encode this data. indent (Union[None, int, str], optional): Number of spaces to indent. Defaults to 2. highlight (bool, optional): Enable highlighting of output: Defaults to True. skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False. ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False. check_circular (bool, optional): Check for circular references. Defaults to True. allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True. default (Callable, optional): A callable that converts values that can not be encoded in to something that can be JSON encoded. Defaults to None. sort_keys (bool, optional): Sort dictionary keys. Defaults to False. r)JSONN)r^r~r_r`rarbrVrcz/json must be str. Did you mean print_json(data=z) ?T)rG) rich.jsonrf from_datarrr r) rrdr]r^r~r_r`rarbrVrcrfjson_renderables rf print_jsonzConsole.print_jsons: # <"nn##)-##- OdC(EdXSQ###)-## O ?d 3re)regionrrkcZ|jstjd|xs |j}|9dx}}|j |j |j xs |j }n|\}}}}|j ||}|j||} |j| ||y)aUpdate the screen at a given offset. Args: renderable (RenderableType): A Rich renderable. region (Region, optional): Region of screen to update, or None for entire screen. Defaults to None. x (int, optional): x offset. Defaults to 0. y (int, optional): y offset. Defaults to 0. Raises: errors.NoAltScreen: If the Console isn't in alt screen mode. 0Alt screen must be enabled to call update_screenNrr) rr( NoAltScreenrrrwrnrupdate_screen_lines) rrrkrrrrrmrnrs rf update_screenzConsole.update_screens&!!$$%WX X 0DLL >IA+==((.*?*?*N4;;N#) Aq%+==eVLN!!*n!E   1-rerrrc|jstjdt|||}|j |}|j j ||jy)aUpdate lines of the screen at a given offset. Args: lines (List[List[Segment]]): Rendered lines (as produced by :meth:`~rich.Console.render_lines`). x (int, optional): x offset (column no). Defaults to 0. y (int, optional): y offset (column no). Defaults to 0. Raises: errors.NoAltScreen: If the Console isn't in alt screen mode. rmN)rr(rnrr9rrr)rrrr screen_updaters rfrozConsole.update_screen_linessY!!$$%WX X$UAq1 ;;}- H% rerTr"rdrmrr word_wrap show_localssuppress max_framesrrtrurvrwc Pddlm}||||||||} |j| y)a Prints a rich render of the last exception and traceback. Args: width (Optional[int], optional): Number of characters used to render code. 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. 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. r') TracebackrsN)rryr) rrmrrrtrurvrwryrs rfprint_exceptionzConsole.print_exception.s4, )##!  9rer currentframec<|dz }|}|K|r||j}|dz}|r||J|jj|j|jfSt j |}|j|j|jjfS)aEGet caller frame information. Args: offset (int): the caller offset within the current frame stack. currentframe (Callable[[], Optional[FrameType]], optional): the callable to use to retrieve the current frame. Defaults to ``inspect.currentframe``. Returns: Tuple[str, int, Dict[str, Any]]: A tuple containing the filename, the line number and the dictionary of local variables associated with the caller frame. Raises: RuntimeError: If the stack offset is invalid. r') f_backf_code co_filenamef_linenof_localsinspectstackfilenamelinenoframe)rr{r frame_infos rf_caller_frame_infozConsole._caller_frame_infoQs( !   U. ! U.$ $$<<++U^^U^^K K!0J&& (9(9:;K;K;T;TT Tre) r3rrr{rNrr~ log_locals _stack_offsetrrc | s tf} |jdd} |5|j| ||||||} || D cgc]} t| |} } |j | \}}}|j drdnt jj|}|jt jd}|rP|jDcic]\}}|j ds||}}}| jt|d|j|| |j|||g} | D]}|j!| } g}|j"}|j$}|j&}| D]} ||| ||j(j"}t+j,||j.d D] }||  dddycc} wcc}}w#1swYyxYw) aXLog rich content to the terminal. Args: objects (positional args): Objects to log to the terminal. sep (str, optional): String to write between print data. Defaults to " ". end (str, optional): String to write at end of print data. Defaults to "\\n". style (Union[str, Style], optional): A style to apply to output. Defaults to None. justify (str, optional): One of "left", "right", "center", or "full". Defaults to ``None``. emoji (Optional[bool], optional): Enable emoji code, or ``None`` to use console default. Defaults to None. markup (Optional[bool], optional): Enable markup, or ``None`` to use console default. Defaults to None. highlight (Optional[bool], optional): Enable automatic highlighting, or ``None`` to use console default. Defaults to None. log_locals (bool, optional): Boolean to enable logging of locals where ``log()`` was called. Defaults to False. _stack_offset (int, optional): Offset of caller from end of call stack. Defaults to 1. Nr1<__z [i]locals)r)rPpathline_no link_pathFrV)rr{r>rGrrr%rabspathrr3itemsrrBrrrUr6rr9rrrDrrm)rr3rrr{rNrr~rrr2rZrrrrlocalsrrkeyr locals_maprr[rr9rr\rs rflogz Console.logts8ylG))!, . $33#4K KVWZvj%8W W(,(?(? (N %Hgv ( 3 3C 8bggooh>WI&&rvv.r2D'-lln"U>>$/J  ""< +#NO  !..0#' ! K% D"66{C  D*,L!((F[[F!\\N) ; vj.9: ; LL//M44djje $d# $W. $. $X #. $. $s*G"GBG"G/CG" G""G+c p|jr|jdd=y|j5|jr=|j5|j j |jddddd|jdk(rG|jrFddl m }||j|j|jdd|jdd=ntrd}|jrt|j}||t v}|rlddlm}ddlm}|jdd}|j*r*|j,rt/t1j2|}||||jn*|j|jdd}|jj4}d} t7|| kr ||ng} | j8} d} |j;d D]T} | t7| z| kDr+| r)|d j=| | j?d} | | | t7| z } V| r'|d j=| | j?n:|j|jdd} |jj5||jjE|jdd=dddy#1swYjxYw#t@$r}|jBd |_!d}~wwxYw#t@$r}|jBd |_!d}~wwxYw#1swYyxYw) aQCheck if the buffer may be rendered. Render it if it can (e.g. Console.quiet is False) Rendering is supported on Windows, Unix and Jupyter environments. For legacy Windows consoles, the win32 API is called directly. This method will also record what it renders if recording is enabled via Console.record. Nrr')displayF)LegacyWindowsTerm)legacy_windows_renderi TrzG *** You may need to add PYTHONIOENCODING=utf-8 to your environment ***)#rJrrrMrwrzrrrajupyterrrr=rur-rI_STD_STREAMS_OUTPUTrich._win32_consolerrich._windows_rendererrrKrmrrD remove_colorwriterrrXr9rUnicodeEncodeErrorreasonflush)rruse_legacy_windows_renderfilenorrrrr MAX_WRITEbatch batch_appendrtrr0s rfrzConsole._check_buffers :: Q  ZZD ({{--@''..t||A?@!!Q&??0DLL$*=*=dll1o*NO Q491..%/ %:F%1$*.A$A!:5MT%)\\!_F#}}1C1C)-g.B.B6.J)K1&:KDII:VW$(#6#6t||A#GD%)IIOOE(6I&#&t9 #9$)$K79E38<>LL, L)L$$L))L,,L5rc>g}|j}|j}|j}|j }|jr|rt j |}|D]0\}}} |r||j|||$|r| r)||2dj|} | S)z)Render buffered output, and clear buffer.)rCrur) rrmrurxrKrDrr9r9) rroutputrrCru not_terminalrrrrendereds rfrzConsole._render_buffers)) ,,+++ ==\))&1F$*  D%LL%1'5!#wt  776?re)rrNpasswordstreampromptrrc|r|j|||d|rtd|}|S|r|j}|St}|S)a5Displays a prompt and waits for input from the user. The prompt may contain color / style. It works in the same way as Python's builtin :func:`input` function and provides elaborate line editing and history features if Python's builtin :mod:`readline` module is previously loaded. Args: prompt (Union[str, Text]): Text to render in the prompt. markup (bool, optional): Enable console markup (requires a str prompt). Defaults to True. emoji (bool, optional): Enable emoji (requires a str prompt). Defaults to True. password: (bool, optional): Hide typed text. Defaults to False. stream: (TextIO, optional): Optional file to read input from (rather than stdin). Defaults to None. Returns: str: Text read from stdin. r)rrNr)r)rr readlineinput)rrrrNrrresults rfrz Console.input,sW.  JJvfErJ B R/F  *  rerrrc |jsJd|j5|r#djd|jD}n"djd|jD}|r|jdd=ddd|S#1swYSxYw)aGenerate text from console contents (requires record=True argument in constructor). Args: clear (bool, optional): Clear record buffer after exporting. Defaults to ``True``. styles (bool, optional): If ``True``, ansi escape codes will be included. ``False`` for plain text. Defaults to ``False``. Returns: str: String containing console contents. ITo export console contents set record=True in the constructor or instancerc3NK|]\}}}|r|j|n|ywrr8)rGrr_s rfrIz&Console.export_text..`s.&eQ,1U\\$'d:s#%c3LK|]}|js|jywr)rrrUs rfrIz&Console.export_text..es#"??LLs"$N)rMrwr9rz)rrrrs rf export_textzConsole.export_textNs KK W V W  % % +ww*.*=*= ww#'#6#6 ''* +  + s ABB rc|j||}t|dd5}|j|dddy#1swYyxYw)aGenerate text from console and save to a given location (requires record=True argument in constructor). Args: path (str): Path to write text files. clear (bool, optional): Clear record buffer after exporting. Defaults to ``True``. styles (bool, optional): If ``True``, ansi style codes will be included. ``False`` for plain text. Defaults to ``False``. rwtrryN)ropenr)rrrrr write_files rf save_textzConsole.save_textnsJeF; $w / #:   T " # # #s =Arr code_format inline_stylesrrc ~|jsJdg}|j}|xst}d}|tn|} |j5|rt j t j|jD]X\} } } t| } | r=| j|} | jrd| jd| d} | r d| d| dn| } || Zni}t j t j|jD]v\} } } t| } | r[| j|} |j| t|d z}| jrd |d | jd| d} n d |d| d} || xg}|j}|jD]\}}|s |d |d|ddj|}| j!dj|||j"j$|j&j$}|r|jdd=ddd|S#1swYSxYw)aIGenerate HTML from console contents (requires record=True argument in constructor). Args: theme (TerminalTheme, optional): TerminalTheme object containing console colors. clear (bool, optional): Clear record buffer after exporting. Defaults to ``True``. code_format (str, optional): Format string to render HTML. In addition to '{foreground}', '{background}', and '{code}', should contain '{stylesheet}' if inline_styles is ``False``. inline_styles (bool, optional): If ``True`` styles will be inlined in to spans, which makes files larger but easier to cut and paste markup. If ``False``, styles will be embedded in a style tag. Defaults to False. Returns: str: String containing console contents as HTML. rrNz zz D6#QD4L !/1 $4$;$;!06 P,J !)B|nC |2*NOP"YY'78 .55WWY'%!2266!2266 6M ''*Q( +RS( +RsE$H2)A?H22H<c|j||||}t|dd5}|j|dddy#1swYyxYw)a@Generate HTML from console contents and write to a file (requires record=True argument in constructor). Args: path (str): Path to write html file. theme (TerminalTheme, optional): TerminalTheme object containing console colors. clear (bool, optional): Clear record buffer after exporting. Defaults to ``True``. code_format (str, optional): Format string to render HTML. In addition to '{foreground}', '{background}', and '{code}', should contain '{stylesheet}' if inline_styles is ``False``. inline_styles (bool, optional): If ``True`` styles will be inlined in to spans, which makes files larger but easier to cut and paste markup. If ``False``, styles will be embedded in a style tag. Defaults to False. rrrrN)rrr)rrrrrrhtmlrs rf save_htmlzConsole.save_htmlsX,#'    $w / #:   T " # # #s ?ARichgQ?rrrrfont_aspect_ratio unique_idrrc345678ddlm}i7dtdtf37fd }|xst3|j 8d} | |z4| dz5d} d} d} d} d }d }d }d }||z}||z}| | z}| | z}g}g}i}d}d tdtfd } d2dtdt tdtdtfd6|j5ttj|j}|r|jjd d d Zdttjdj!dDj#dd|j#ddzzd}t%tj&8D]\}}d}|D]\}} }!| xs t} || }"|"|vr |||"<|dz }d||"}#| j(rJd}$| j*3j,j.n$| j*j13j.}%nf| j2}&|&d uxr |&j4 }$| j23j6j.n$| j2j13j.}%||}'|$r-|j96d|%|4z|5zdz4|'z5dzd|dt;|zk7rE|j96d ||d |#|4z|5z| z4t;|zd!d"|d#$|||z }t=|D(cgc] }(|(5zdz })}(d%j!4568fd&t%|)D}*d%j!fd'|j?D}+dj!|},dj!|}-tA84z|z}.|dz5z|z}/6d3j6j.d(d)| | |.|/d * }03j,j.}1|r$|06d ||d+|1d,|.d-z| | zd.z/z }0|0d0z }0|jC4| 548zdz |dz5zdz |.|z|/|z| |z| |z|+|0|,|-|*1}2|2S#1swYoxYwcc}(w)3a Generate an SVG from the console contents (requires record=True in Console constructor). Args: title (str, optional): The title of the tab in the output image theme (TerminalTheme, optional): The ``TerminalTheme`` object to use to style the terminal clear (bool, optional): Clear record buffer after exporting. Defaults to ``True`` code_format (str, optional): Format string used to generate the SVG. Rich will inject a number of variables into the string in order to form the final SVG output. The default template used and the variables injected by Rich can be found by inspecting the ``console.CONSOLE_SVG_FORMAT`` variable. font_aspect_ratio (float, optional): The width to height ratio of the font used in the ``code_format`` string. Defaults to 0.61, which is the width to height ratio of Fira Code (the default font). If you aren't specifying a different font inside ``code_format``, you probably don't need this. unique_id (str, optional): unique id that is used as the prefix for various elements (CSS styles, node ids). If not set, this defaults to a computed value based on the recorded content. r)cell_lenrrc|vr|Sg}|j|jjr jn|jj}|j|jjr j n|jj}|j r||}}|jr t||d}|jd|j|jr|jd|jr|jd|jr|jd|jr|jddj|}||<|S)z%Convert a Style to CSS rules for SVG.g?zfill: zfont-weight: boldzfont-style: italic;ztext-decoration: underline;ztext-decoration: line-through;;)color is_defaultr get_truecolorbgcolorrreversedimr3rrbolditalic underlinestriker9)r css_rulesrrcssr style_caches rf get_svg_stylez)Console.export_svg..get_svg_style sD #"5))IKK'5;;+A+A''[[..v6 MM)U]]-E-E'']]008  }}!(%wyy!%#6   veii[1 2zz  !45||  !67  !>?||  !AB((9%C!$K JregQ?r'(r#rc8t|jddS)z.HTML escape text and replace spaces with nbsp.rz )r replacerTs rf escape_textz'Console.export_svg..escape_textA s$<''X6 6reNr)rattribsc dtdtfddjfd|jD}|rd|d|d|d|d Sd|d|d S) z.Make a tag from name, content, and attributes.rrcPt|tr t|dSt|S)Ng)rfloatrr)rs rf stringifyz7Console.export_svg..make_tag..stringifyJ s#ee-!%--5z!rerc3~K|]4\}}|jdjddd|d6yw)rrz=""N)lstripr)rGkvrs rfrIz7Console.export_svg..make_tag..O sD#Aq88C=((c232il^1E#s:=rrz)objectrr9r)r)rr tag_attribsrs @rfmake_tagz$Console.export_svg..make_tagE s|  " "C " ((##MMO#K D6;-q D6; a }B/ rez terminal-rc32K|]}t|ywr)reprrUs rfrIz%Console.export_svg..a sCwT']CrNrr^)lengthrTrectg?? crispEdges)fillrrrmrnshape_renderingrrzurl(#-line-))_classrr textLength clip_pathrc3^K|]$\}}dd|ddd|zdzd&yw) z r rr )rrrmrnz Nrd)rGrr char_width line_heightrrrms rfrIz%Console.export_svg.. sW  yky9 fV:+=kTXFXYZ[  s*-c3<K|]\}}dd|d|dyw).z-rz { z }Nrd)rGrrule_nors rfrIz%Console.export_svg.. s/ 7CsGa {"WIT#c 2 szrgba(255,255,255,0.35)1)rstroke stroke_widthrrrmrnrxz-titlemiddlerg)rr text_anchorrrz )rr char_heightrterminal_widthterminal_heightrmrn terminal_x terminal_yrchrome backgroundsmatrixrr)" rich.cellsrrErrIrmrrrwrrDrrzrzlibadler32r9encoderrrrrrrrrrrrrangerr r)9rrrrrrrrrr# margin_top margin_right margin_bottom margin_left padding_top padding_rightpadding_bottom padding_left padding_widthpadding_height margin_width margin_heighttext_backgrounds text_groupclassesstyle_norrrrrrrrHrules class_namehas_backgroundrr text_lengthr line_offsetsrrr)r*r$r%r( title_colorsvgrrrrrrms9 ` @@@@@@rf export_svgzConsole.export_svgsj6 ((*   3 B**   #44 !D(        $}4 $~5"\1 "]2 &( " "$ 7c 7c 7 15   (  AG   ( % % ,G2243F3FGHH##))+ ,  #c WWC(CCKK ll7H5 6'I  !=!=hu!UV4 $GAtA)-2 $%eX(%e,'%-GENMH  01 ==%)N!;;.//33"[[66v>BB $mmG%,D%8%SASAS=SN!==0//33"]]88@DD 'tn !$++ "!+*n+o3",{":#.#5,8 3T?*%% "'-&/[*#>*n+o ;'1CI'=(-i[qc&C Xd^#e2 $4 $lDI8L+-3L L  $-\#:    GN}}  gg./ $ej0=@Aq5K/.@ ((,,+ "  --11  hE"#F+ $ A%{*Q. F     !##%-1Uk1A5 </"]2"\1!K/#! " M , ,LMs2AQ$#Q1$Q.c|j||||||}t|dd5} | j|dddy#1swYyxYw)a7Generate an SVG file from the console contents (requires record=True in Console constructor). Args: path (str): The path to write the SVG to. title (str, optional): The title of the tab in the output image theme (TerminalTheme, optional): The ``TerminalTheme`` object to use to style the terminal clear (bool, optional): Clear record buffer after exporting. Defaults to ``True`` code_format (str, optional): Format string used to generate the SVG. Rich will inject a number of variables into the string in order to form the final SVG output. The default template used and the variables injected by Rich can be found by inspecting the ``console.CONSOLE_SVG_FORMAT`` variable. font_aspect_ratio (float, optional): The width to height ratio of the font used in the ``code_format`` string. Defaults to 0.61, which is the width to height ratio of Fira Code (the default font). If you aren't specifying a different font inside ``code_format``, you probably don't need this. unique_id (str, optional): unique id that is used as the prefix for various elements (CSS styles, node ids). If not set, this defaults to a computed value based on the recorded content. rrrrN)rGrr) rrrrrrrrrFrs rfsave_svgzConsole.save_svg s\6oo#/  $w / ":   S ! " " "s AA r<)rrPrN)rrrrr)TNrr )rr)}rarbrcror%environrArrrqr7rr$rrMrrprFr5rr.rrrrrrrIsetterrrDrrrNrr2rnrrrrr4rrrrrrrrrrrrCryrxrursrrlrtrrmrnrrrr<rrrrr rrrrrrr:rrr9rErrrrWrr.rr>rLr1rCr4rrPrrjrArprorrz staticmethodrr{rrrrrrrrrrrJrr+rr,rGrIrdrerfrrRsn!F#%**Hgc3h, )-(,,0!%"&# $%)#'04:@3B3D)-9=2604Az$ E F z$ ! z$ ~z$$D>z$z$z$z$r#wz$z$}z$ z$  "!z$"4.#z$$%z$&'z$()z$*+z$, --z$./z$01z$23z$4s$6675z$6/07z$8!9z$:;z$<xH 56=z$>8BI./?z$@738,-Az$xF#Fbg [[RW*g**0s00131411/j// h{&; 0   ,Z,D,%   S ;? = =4 =4 =&:> 2u 2$ 2, 2 hsm  L#LL!T!!F ,$ , ,      + '+ + Z [[U38_s \\34    ]]ST%$RWKe_K59KJNK K.###d# *$ *$ *#3$(!! ! ! !  !"! !B   TT*#t##cdBFJ O O/7 /B O  ORV(6>~6N $OS1@(1@3;N3K1@ ' 1@l-19 "&9"9.)9  9  99 d7m 9~$&+/-1 $!%$(1599S%Z 9 -( 9 >* 9~99D>9o.9 9xRV#u*%3;E%*I  IZ #.%   S%Z    *NNDN-1$(      c5j)*  D>    F-1+/-1"& $!%$(# $$($!a2a2a2 a2 c5j)* a2 -( a2>*a2$a2~a2a2D>a2}a2 a2a2D>a2 !a2" #a2J#;4()"#26;4sm;4 ;4 dCn% ;4  ;4;4;4;4;4(C5#:./;4;4 ;4B$(,0 ." . . .) .  .F@A$w-(-09< . ##!57!}! ! } !  !!5j12!! !F;B:N:N U Ur8I#667 U sCc3h' ( U UJ-1+/ $!%$( O$O$O$ O$ c5j)* O$ -( O$~O$O$D>O$O$O$ O$bM(^Xg%634 #'           D,0D#@59 #c #T #$ #SW #"*.%)# I &I I c] I  I I^*..### & #  #  ## #D)--#'#'yy & y  y  y!yC=y y~)--#'#'$"$" $"  & $"  $"$"!$"C=$" $"rer svg_main_codecZttj|jS)zReturns a unique hash for the given SVG main code. Args: svg_main_code (str): The content we're going to inject in the SVG envelope. Returns: str: a hash of the given content )rr,r-r.)rMs rf _svg_hashrO s! t||M0023 44re__main__)rMzJSONRPC [i]request[/i]g?Fz2.0subtract*)minuend subtrahendr")jsonrpcrparamsidz Hello, World!z{'a': 1}z&Which one is correct team name in NBA?)zNew York BullszLos Angeles KingszGolden State Warriors Huston RocketrZ)questionranswer)answeredq1z 5 + 7 = ?) raz 12 - 8 = ?)r'rgr"rc)r]r^q2)sportmaths)r)emptyquizr)rrO)rr%platformrrpr,abcrr dataclassesrrr functoolsrr rr r itertoolsr mathr timertypesrrrtypingrrrrrrrrrrrrrrr rich._null_filer! version_infor$r%r&typing_extensionsrr(r)r*_export_formatr+r,_filenor-rrr.r/r@r0r1rr2r3rr4rNr5rSr6r7rr9r!rr:r;rr<r=prettyr>r?protocolr@rkrAscoperBrrCrFrDrrErFstyledrGterminal_themerHrIrJrrKrLrrMrNr;rOrrPrrRrcrdsystemr=rrWrrr`r __stdin__r _STDIN_FILENO Exception __stdout___STDOUT_FILENO __stderr___STDERR_FILENOrrrrrrlrsrrr rrsrrrrrrrrrrr)rrorrlocalr/r4r7rqr:r?rrOrarrr r)r)r|s00rfrs   #(66$&v;; *C6%)9+5%)#SS $0 (// y (E#v+./78DE =>   J MM((*M^^**,N^^**,N~~> %~6 " "%%## . . BB BJ x     ((C78:ng567 #%393 ) )$B!!*$%$%N,/,/^$$BtxXc5j-A(AB,T*$$  &&""  :G9L9L9NOv O )//   &AE8$<=D%=t= s"s"l= 5S 5S 5 zT"G KK       "$B7    KKT']; MM!%$L$ #2  !&$/#3"$ %1#/"#  !)mMMNNv Ps<1PP"+P0; P>PP"P-,P-0P;:P;