U ʗRev @sUddlZddlZddlZddlZddlZddlZddlZddlmZm Z ddl m Z m Z ddl m Z ddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZmZmZdd lmZm 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,m-Z-ej.dkr4ddlm/Z/m0Z0m1Z1nddl2m/Z/m0Z0m1Z1ddl3m4Z4m5Z5ddl6m6Z6ddl7m8Z8m9Z9ddl:m;Z;mZ>m?Z?ddl@mAZAmBZBddlCmDZDddlEmFZFddlGmHZHmIZIddlJmKZLddlMmNZNmOZOddlPmQZQmRZRddlSmTZTmUZUddlVmWZWddlXmYZYdd lZm[Z[dd!l\m]Z]dd"l^m_Z_dd#l`maZambZbdd$lcmdZddd%lemfZfmgZgmhZhdd&limjZjmkZkdd'llmmZmmnZne rdd(lompZpdd)lqmrZrdd*lsmtZtd+Zud,Zvewd-kZxe"e,eyd.fgd.fZze/d/Z{e/d0Z|Gd1d2d2Z}e}Z~zejZWnek r4dZYnXzejZWnek r^dZYnXzejZWnek rd3ZYnXeeefZeefZeAjeAjd4ZGd5d6d6e'Ze Gd7d8d8Ze1Gd9d:d:e0Ze1Gd;d<dd>eZGd?d@d@ZGdAdBdBZGdCdDdDZGdEdFdFZGdGdHdHZGdIdJdJZGdKdLdLZdee"dNe"dNeffdOdPdQZedRdSdTZeAjeAjeAjeAjxdUZdVdWeDZe GdXdYdYejZGdZd[d[eZdae(d\ed]<d\dRd^d_ZedRd`daZGdbdcdcZeyeydddedfZedgkredMdhZedidjdkdMdlddmdndodpdqdrdsedtdueeedgdMdvdwdxdydzgdzd{d|dld}d~dddgdd{ddd3drdgdd{ddddS)N)ABCabstractmethod) dataclassfield)datetime)wraps)getpass)escape)isclass)islice)ceil) monotonic) FrameType ModuleType TracebackType)IO TYPE_CHECKINGAnyCallableDictIterableListMapping NamedTupleOptionalTextIOTupleTypeUnioncast))LiteralProtocolruntime_checkable)errorsthemes)_emoji_replace)CONSOLE_HTML_FORMATCONSOLE_SVG_FORMAT)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 StyleTypeStyled)DEFAULT_TERMINAL_THEMESVG_EXPORT_THEME TerminalTheme)TextTextType)Theme ThemeStack)WindowsConsoleFeatures)LiveStatussdWindowsrI)defaultleftcenterrightfull)foldcropellipsisignorec@s eZdZdS)NoChangeN)__name__ __module__ __qualname__rara/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/rich/console.pyr]Tsr])256color16colorc@s"eZdZUdZeed<eed<dS)ConsoleDimensionszSize of the terminal.widthheightN)r^r_r`__doc__int__annotations__rarararbrfns rfc @seZdZUdZeed<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<eedddZddddZeeeeeeeeed eeefeeefeeefee e efee e efee eefee eefee eefee eefdd ddZeddddZeddddZddd d!Zeedd"d#d$Zd S)%ConsoleOptionsz$Options for __rich_console__ method.sizelegacy_windows min_width max_width is_terminalencoding max_heightNjustifyoverflowFno_wrap highlightmarkuprhreturncCs|jd S)z+Check if renderables should use ascii only.utf)rr startswithselfrararb ascii_onlyszConsoleOptions.ascii_onlycCstt}|j|_|S)zdReturn a copy of the options. Returns: ConsoleOptions: a copy of self. )rl__new____dict__copyr~optionsrararbrs  zConsoleOptions.copy) rgrorprtrurvrwrxrh) rgrorprtrurvrwrxrhrzc Cs|} t|ts$td|| _| _t|ts4|| _t|tsD|| _t|tsT|| _t|tsd|| _t|tst|| _t|ts|| _ t|ts|| _ t| ts| dk r| | _ | dkrdntd| | _ | S)zUpdate values, return a copy.rN) r isinstancer]maxrorprtrurvrwrxrsrh) r~rgrorprtrurvrwrxrhrrararbupdates,         zConsoleOptions.updatergrzcCs|}td||_|_|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)rrrorp)r~rgrrararb update_widths zConsoleOptions.update_widthrhrzcCs|}||_|_|S)zUpdate the height, and return a copy. Args: height (int): New height Returns: ~ConsoleOptions: New Console options instance. )rrsrh)r~rhrrararb update_heights  zConsoleOptions.update_heightcCs|}d|_|S)zReturn a copy of the options with height set to ``None``. Returns: ~ConsoleOptions: New console options instance. N)rrhrrararb reset_heightszConsoleOptions.reset_height)rgrhrzcCs*|}td||_|_||_|_|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)rrrorprhrs)r~rgrhrrararbupdate_dimensionss  z ConsoleOptions.update_dimensions)r^r_r`rirfrkboolrjstrrtr JustifyMethodruOverflowMethodrvrwrxrhpropertyrr NO_CHANGErr]rrrrrrarararbrlwsT      %   rlc@s(eZdZdZeddefdddZdS)RichCastz5An object that may be 'cast' to a console renderable.ConsoleRenderablerycCsdSNrar}rararb__rich__szRichCast.__rich__N)r^r_r`rirrrrarararbrs rc@s"eZdZdZddddddZdS) rz-An object that supports the console protocol.Consolerl RenderResultconsolerrzcCsdSrrar~rrrararb__rich_console__ sz"ConsoleRenderable.__rich_console__N)r^r_r`rirrarararbrs rc@seZdZdZdS) CaptureErrorz(An error in the Capture context manager.N)r^r_r`rirarararbrsrc@s8eZdZdZd eddddZddeed d d ZdS) NewLinez$A renderable to generate new line(s)r%NcountrzcCs ||_dSr)rr~rrararb__init__!szNewLine.__init__rrlrccstd|jVdS)N )rArrrararbr$szNewLine.__rich_console__)r%) r^r_r`rirjrrrArrarararbrs rc@s>eZdZdZeeeeeddddZdee ddd Z dS) ScreenUpdatez)Render a list of lines at a given offset.NlinesxyrzcCs||_||_||_dSr)_linesrr)r~rrrrararbr-szScreenUpdate.__init__rrccs>|j}tj}t|j|jD]\}}|||V|EdHqdSr)rr1move_to enumeraterr)r~rrrroffsetlinerararbr2s  zScreenUpdate.__rich_console__) r^r_r`rirrArjrrlrrrarararbr*s rc@s`eZdZdZdddddZdddd Zeeeeeee dd d d Z e dd dZ dS)CapturezContext manager to capture the result of printing to the console. See :meth:`~rich.console.Console.capture` for how to use. Args: console (Console): A console instance to capture output. rN)rrzcCs||_d|_dSr)_console_result)r~rrararbrDszCapture.__init__rycCs|j|Sr)r begin_capturer}rararb __enter__Hs zCapture.__enter__exc_typeexc_valexc_tbrzcCs|j|_dSr)r end_capturerr~rrrrararb__exit__LszCapture.__exit__cCs|jdkrtd|jS)zGet the result of the capture.Nz.decorator.._replace)rrr)rrr)rrb decoratorszgroup..decorator)rrrr)rrrarrbgroups  rrycCs\ztWntk rYdSXt}|jj}dt|jksD|dkrHdS|dkrTdSdSdS)z-Check if we're running in a Jupyter notebook.Fz google.colabZMQInteractiveShellTTerminalInteractiveShellN) get_ipython NameError __class__r^r)ipythonshellrararb _is_jupytersr)standard256 truecolorwindowscCsi|]\}}||qSrara).0namesystemrararb src@s<eZdZUdZeed<eedZe e ed<dZ e ed<dS)ConsoleThreadLocalsz(Thread local values for Console context. theme_stack)default_factoryrr buffer_indexN) r^r_r`rirLrkrrrrrArrjrarararbrs rc@s,eZdZdZeeeeedddZdS) RenderHookz(Provides hooks in to the render process.)rrzcCsdS)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. Nra)r~rrararbprocess_renderables%szRenderHook.process_renderablesN)r^r_r`rirrrrrarararbr"s rrM_windows_console_featurescCs"tdk r tSddlm}|atS)Nr%get_windows_console_features)r_windowsrrrararbr8s  rcCsto tj S)zDetect legacy Windows.)WINDOWSrvtrarararbdetect_legacy_windowsBsr c @seZdZUdZejZeeefe d<dddddddddddddddddddddde dddddd e e d e e e e e e e e ee e eee e ee ee ee e ee e e e ee e e eeefe d e e e e egefe egefe eeefd d d ZedddZeeedddZejeeddddZeeedddZeedddZ e jeddddZ ee!dddZ"e e#dddZ$dddd Z%ddd!d"Z&d#dd$d%d&Z'ddd'd(Z(e)dd)d*d+Z*ddd,d-Z+ddd.d/Z,e-e-e-dd0d1d2Z.ddd3d4Z/edd5d6Z0dd7ee dd8d9d:Z1ddd;d<Z2dd7ee e3d8d=d>Z4ee edd?d@Z5eeddAdBZ6ee ddCdDZ7ee ddEdFZ8ee9ddGdHZ:ee;ddIdJZe>jeddOdPdNZ>eeddQdRZ?e?jeddSdTdRZ?dddUdVZ@eAddWdXZBde eCe e eDdYdZd[ZEdedd]d^d_ZFde dd`dadbZGdcdddedfdgeHeeeedhdidjdkZIde e dldmdnZJde e dodpdqZKee ddrdsZLee dtdudvZMde e edwdxdydzZNdd{eHe e9eOd|d}d~ZPdeHe e9eQed|ddZRdddddeHe e9e eSe e eeedddZTddddddddeeeeSfe eUe eVe e e e e e e eWdd ddZXddeeeSfe eeSefeSdddZYdddddeQe-eee eUe e e e e e eeZdddZ[ddddde\eeeeSfe]ddddZ^e_ddddZ`ddddde-eee eeeSfe e ddddZaddddddddddddddde-eee eeeSfe eUe eVe e e e e e e e e ee ee e e e ddddZbddddddddddd e ee-edeefe e e e e e ee-ge-fe dd ddZcdddeHe ede e9ddddZedeeeeeddddZfdddddddde eee ee e eQeeegfeddddZheiejjkfeege elfe=eeemee-ffdddZnddddddddd\d e-eee eeeSfe eUe e e e e e e edd ddZoddddÄZpeQeedĜddƄZqddddddǜe\e e e e eredȜddʄZsddd˜e e ed̜dd΄Ztddd˜ee e ddϜddфZudddddҜe eve e ee edӜddՄZwddexddҜee eve ee dd֜dd؄Zydddezdڜee eve eedۜdd݄Z{dddezdڜeee eve eddޜddZ|dS)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_wraprstderrfilequietrgrhrno_colortab_sizerecordrxemoji emoji_variantrwlog_timelog_pathlog_time_format highlighterrnsafe_box get_datetimeget_timer )r rrrrHighlighterTypec!Cs\|dk r||_|dkrtn||_|jr| dkrZ|jd}|dk rV|rVt|} nt} | dkr|jd}|dk r|rt|} nt} ||_||_ ||_ ||_ ||_ ||_ |dkrto|j n||_| dkr|jd}|dk r|rt||j} | dkr0|jd} | dk r0| r0t| } ||_| |_| |_|||_||_| |_||_|dkrpd|_n |dkr||_n t||_t|_t|||d|_|pt|_ ||_!|pt"j#|_$|pt%|_&| |_'| dk r| nd|jk|_(|dkr|j)o|j* n||_+t|_,t-t.|dkr4t/j0n|d|_1g|_2g|_3d|_4d |_5dS) NJUPYTER_COLUMNS JUPYTER_LINESCOLUMNSLINESr ) show_time show_path time_formatNO_COLOR)rF)6r r is_jupyterrisdigitrjJUPYTER_DEFAULT_COLUMNSJUPYTER_DEFAULT_LINESrr_markup_emoji_emoji_variant _highlightr rnr_width_height_force_terminal_filerr _color_system_detect_color_system COLOR_SYSTEMS threadingRLockrr, _log_render_null_highlighterrrrnowrr rrrrqis_dumb_terminalis_interactive_record_buffer_lockrrLr'DEFAULT_thread_locals_record_buffer _render_hooks_live_is_alt_screen)!r~r r rrrrrrrrgrhrrrrrxrrrwrrrrrnrrrr jupyter_columns jupyter_linescolumnsrrararbrms#               zConsole.__init__rycCsd|jdt|jdS)Nz)rgrr5r}rararb__repr__szConsole.__repr__cCs(|jp|jrtjntj}t|d|}|S)z Get the file object to write to.rich_proxied_file)r4rsysstdoutgetattr)r~rrararbrs z Console.file)new_filerzcCs ||_dS)zSet a new file object.N)r4)r~rPrararbrscCs|jjSzGet a thread local buffer.)rArr}rararbrszConsole._buffercCs|jjSrQrArr}rararb _buffer_indexszConsole._buffer_indexvaluerzcCs ||j_dSrrR)r~rUrararbrSscCs|jjS)z!Get the thread local theme stack.)rArr}rararb _theme_stackszConsole._theme_stackcCs|jr tjS|jr|jrdStrD|jr,tjSt}|jr>tjStj S|j dd }|dkrhtjS|j dd }|d\}}}t |tj}|SdS)z"Detect color system from env vars.N COLORTERMr)r24bitTERM-)r)r/ TRUECOLORrqr=rrnrr EIGHT_BITr rstriplower rpartition _TERM_COLORSSTANDARD)r~windows_console_features color_termterm _term_name_hyphencolorsr rararbr6s& zConsole._detect_color_systemcCs|jd7_dS)z4Enter in to a buffer context, and buffer all output.r%N)rSr}rararbrszConsole._enter_buffercCs|jd8_|dS)z5Leave buffer context, and render content if required.r%N)rS _check_bufferr}rararbr#szConsole._exit_bufferrN)liverzc Cs0|j |jdk rtd||_W5QRXdS)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)rrDr& LiveError)r~rirararbset_live(s   zConsole.set_livec Cs|j d|_W5QRXdS)zClear the Live instance.N)rrDr}rararb clear_live6szConsole.clear_live)hookrzc Cs"|j|j|W5QRXdS)zpAdd a new render hook to the stack. Args: hook (RenderHook): Render hook instance. N)rrCappend)r~rmrararbpush_render_hook;szConsole.push_render_hookc Cs |j|jW5QRXdS)z'Pop the last renderhook from the stack.N)rrCpopr}rararbpop_render_hookDszConsole.pop_render_hookcCs ||S)z,Own context manager to enter buffer context.rr}rararbrIszConsole.__enter__)r exc_value tracebackrzcCs |dS)zExit buffer context.N)r)r~rrsrtrararbrNszConsole.__exit__cCs |dS)z`Begin capturing console output. Call :meth:`end_capture` to exit capture mode and return output.Nrrr}rararbrRszConsole.begin_capturecCs$||j}|jdd=||S)zhEnd capture mode and return captured string. Returns: str: Console output. N)rrr)r~ render_resultrararbrVs  zConsole.end_capturer)rrrzcCs|jj||ddS)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. rvN)rVrr~rrrararbras zConsole.push_themecCs|jdS)z9Remove theme from top of stack, restoring previous theme.N)rVrr}rararbrlszConsole.pop_themecCs t|||S)aUse a different theme for the duration of the context manager. Args: theme (Theme): Theme instance to user. inherit (bool, optional): Inherit existing console styles. Defaults to True. Returns: ThemeContext: [description] )rrwrararb use_themeps zConsole.use_themecCs|jdk rt|jSdSdS)zpGet color system string. Returns: Optional[str]: "standard", "256" or "truecolor". N)r5_COLOR_SYSTEMS_NAMESr}rararbr |s  zConsole.color_systemcCst|jddpdS)zGet the encoding of the console file, e.g. ``"utf-8"``. Returns: str: A standard encoding string. rrutf-8)rOrr^r}rararbrrszConsole.encodingcCsl|jdk r|jSttjdr.tjjdr.dSt|jdd}z|dkrJdn|WStk rfYdSXdS)zCheck if the console is writing to a terminal. Returns: bool: True if the console writing to a device capable of understanding terminal codes, otherwise False. Nr_idlelibFisatty) r3hasattrrMstdinr_r|rOr ValueError)r~r|rararbrqs zConsole.is_terminalcCs$|jdd}|dk}|jo"|S)zxDetect dumb terminal. Returns: bool: True if writing to a dumb terminal, otherwise False. rYr)dumbunknown)r rr^rq)r~_termis_dumbrararbr=s zConsole.is_dumb_terminalc Cs$t|jj|j|jd|j|j|jdS)zGet default console options.r%)rsrmrnrorprrrq)rlrmrhrnrgrrrqr}rararbrszConsole.optionsc Cs<|jdk r(|jdk r(t|j|j|jS|jr8tddSd}d}trrzt\}}Wqtt t fk rnYqXn>> 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)r~capturerararbr&szConsole.capture)rrrrzcCst||||dS)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)r~rrrrararbr7sz Console.pagerr%rcCs"|dkstd|t|dS)zqWrite new line(s). Args: count (int, optional): Number of new lines. Defaults to 1. rzcount must be >= 0N)AssertionErrorrrrrararbrNsz Console.line)homerzcCs,|r|ttn|tdS)zClear the screen. Args: home (bool, optional): Also move the cursor to 'home' position. Defaults to True. N)rr1clearr)r~rrararbrXsz Console.cleardotszstatus.spinnerg?g)@)spinner spinner_stylespeedrefresh_per_secondrP)statusrrrrrzcCs$ddlm}|||||||d}|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%rO)rrrrr)rrP)r~rrrrrrPstatus_renderablerararbrcs zConsole.status)rrzcCs|jr|t|dSdS)zqShow or hide the cursor. Args: show (bool, optional): Set visibility of the cursor. TF)rqrr1r)r~rrararbrszConsole.show_cursor)enablerzcCs.d}|jr*|js*|t|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)rqrnrr1 alt_screenrE)r~rchangedrararbrs  zConsole.set_alt_screencCs|jS)zCheck if the alt screen was enabled. Returns: bool: True if the alt screen was enabled, otherwise False. )rEr}rararb is_alt_screenszConsole.is_alt_screen)titlerzcCs|jr|t|dSdS)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)rqrr1r)r~rrararbset_window_titleszConsole.set_window_titler)rrrzcCst|||p ddS)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)r~rrrararbrs zConsole.screenr)rrrzcCst||p|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. )r7rr)r~rr measurementrararbmeasureszConsole.measurec cs|p|j}|jdkrdSt|}t|dr@t|s@|||}n>t|trl|j||j |j d}|||}nt d|dz t |}Wn&tk rt d|dYnXt}|}|D](}t||r|Vq|||EdHqdS) 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)rwrxzUnable to render zC; A str, Segment or object with __rich_console__ method is requiredzobject z is not renderable)rrpr=r}r rrr render_strrwrxr&NotRenderableErroriter TypeErrorrArr6) r~rr_optionsrender_iterabletext_renderable iter_render_Segment render_outputrararbr6s8       zConsole.render)rpad new_lines)rrrrrrzc Cs|j|p|j}|||}|r.t||}|j}|dk rFtd|}tttj ||j |||dd|} |jdk r|jt | } | dkr|rtd|j |tdgntd|j |gg} | | | | W5QRSQRXdS)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_linesrrrIr) rrr6rA apply_stylerhrrr split_and_crop_linesrprextend) r~rrrrrrender_options _rendered render_heightr extra_linespad_linerararb render_liness<     zConsole.render_linesr)rrtrurrxrwrrI) textrrtrurrxrwrrzcCs|p|dko|j} |p"|dko"|j} |p4|dko4|j} | rZt||| |jd} || _|| _n"t| rnt||jdn||||d} | r|p|j nd} | dk r| t | }| | |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)rrr)default_variant)rtrur) r.r-r0 render_markupr/rtrurIr(rr copy_styles)r~rrrtrurrxrwr emoji_enabledmarkup_enabledhighlight_enabled rich_text _highlighterhighlight_textrararbrZs4   zConsole.render_str)rT)rrTrzc Cst|tr|Sz2|j|}|dkr.t|}|jr<|n|WStjk r}z6|dk rn| |WYSt d|d|dW5d}~XYnXdS)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; ) rrBrVrparselinkrr&StyleSyntaxError get_style MissingStyle)r~rrTrerrorrararbrs   zConsole.get_stylertrrxrw)objectsseprrtrrxrwrzcs6g}|jgj} dkr:tddfdd } | t} |sP|dkrV|jrV|j} ddfdd } |D]} t| } t| tr| |j| ||| d qtt| t r| | qtt| t r| | qtt | r| t | | d qt| | t| qt| |j dk r2||j fd d |D}|S) 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. )rUrVrWN)rrzcst|ttdSr)r-rr.)r)_appendrtrarb align_appendsz2Console._collect_renderables..align_appendrycs.r*td}|dd=dS)N)rtr)rIjoin)sep_text)rnrrtrrrarb check_textsz0Console._collect_renderables..check_text)rrxr)rcsg|]}t|qSrarDrrrrarb sz0Console._collect_renderables..)rnrr;r0rr=rrrrIrr<r;rr)r~rrrrtrrxrwr append_textrrrrra)rrnrrtrrrrb_collect_renderablessJ       zConsole._collect_renderablesu─z rule.linerV) charactersralign)rrrrrzcCs*ddlm}|||||d}||dS)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)rrrrN)rulerr)r~rrrrrrrararbrs z Console.rule)rrzc Gs0|js,||jdd|DW5QRXdS)zInsert non-printing control codes. Args: control_codes (str): Control codes, such as those that may move the cursor. css|] }|jVqdSr)segment)r_controlrararb sz"Console.control..N)r=rr)r~rrararbrszConsole.controlrIr)rrrrw)rrrrrwrzc Gs4|dd|D}|j|||ddddd|d dS)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``. css|]}t|VqdSr)r)r_objectrararbr0szConsole.out..FTr\)rrwrrxrvrurZrN)rr)r~rrrrwr raw_outputrararboutsz Console.out)rrrrtrurvrrxrwrgrhrZrnew_line_start)rrrrrtrurvrrxrwrgrhrZrrrzc Gs|s tf}| dkr|j} | r:|dkr*d}|dkr6d}d} |jdd}|.|j||||||| d}|D]}||}ql|jj||| dk rt| |jnt | ||| d}g}|j }|j }|dkr|D]}||||qn&|D] }|t |||||q|r:tddd |Dd kr:|d t | rl|jj }t j||jdd D]}||qZn |j |W5QRXdS) 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\Fr)rtrurgrhrvrxrwrcss|] }|jVqdSrrrrrararbrsz Console.print..r%rr)rrrCrrrrminrgrrr6rArrrr splitlinesinsertrrr)r~rrrrtrurvrrxrwrgrhrZrrr render_hooksrrmr new_segmentsrr6r buffer_extendrrararbr=sx%    z Console.printrc) dataindentrw skip_keys ensure_asciicheck_circular allow_nanrT sort_keys) jsonrrrwrrrrrTrrzc Csxddlm} |dkr2| j|||||||| | d } n4t|tsLtd|d| |||||||| | d } |j| dddS) 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)rrwrrrrrTrz/json must be str. Did you mean print_json(data=z) ?T)r)pip._vendor.rich.jsonr from_datarrrr) r~rrrrwrrrrrTrrjson_renderablerararb print_jsons:    zConsole.print_json)regionr)rrrrzc Csz|jstd|p|j}|dkrBd}}||j|jp<|j}n|\}}}}|||}|j||d} || ||dS)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& NoAltScreenrrrprhrupdate_screen_lines) r~rrrrrrrgrhrrararb update_screens     zConsole.update_screenrrcCs>|jstdt|||}||}|j||dS)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. rN)rr&rrr6rrrh)r~rrr screen_updaterrararbrs     zConsole.update_screen_linesrRr rargrr word_wrap show_localssuppress max_frames)rgrrrrrrrzc Cs0ddlm}||||||||d} || dS)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%) TracebackrN)rtrr) r~rgrrrrrrrrtrararbprint_exceptions  zConsole.print_exception)r currentframerzcCsr|d7}|}|dk rP|r2|dk r2|j}|d8}q|dk s>t|jj|j|jfSt|}|j|j |j jfSdS)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%N) f_backrf_code co_filenamef_linenof_localsinspectstackfilenamelinenoframe)rrr  frame_inforararb_caller_frame_info6s    zConsole._caller_frame_info) rrrrtrrxrw log_locals _stack_offset) rrrrrtrrxrwrrrzc  sN| s tf} |jdd} |$|j| ||||||d} dk rTfdd| D} || \} }}| drrdn tj| }| tj d}|rdd| D}| t |d d |j || ||||d g} | D]}|| } qg}|j}|j}|j}| D]}||||q|jj}tj||jd d D]}||q0W5QRXdS)aLog 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``. overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". 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. Nrcsg|]}t|qSrarDrrrarbrszConsole.log...z [i]locals)r)rpathline_no link_pathFr)rrCrrr|rrabspathr_ritemsrnr?r:rrrr6rrrArrg)r~rrrrtrrxrwrrrrrr rlocalsrr locals_maprmrrr6rrrrrarrblogYs^    z Console.logc Cs|jr|jdd=dS|j|jrN|j|j|jddW5QRX|jdkr|jrddl m }||j| |jdd|jdd=nZt rd}|j rz|jtk}Wnttjfk rYnX|rddlm}ddlm}||jdd||jnp| |jdd}|jj}|dD]H}z ||Wn4tk rz}z|jd |_W5d}~XYnXq6nZ| |jdd}z|j|Wn4tk r}z|jd |_W5d}~XYnX|j|jdd=W5QRXdS) 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_renderTzG *** You may need to add PYTHONIOENCODING=utf-8 to your environment ***)rrrrr?rBrrSr)jupyterrrrrnrfileno_STD_STREAMS_OUTPUTrioUnsupportedOperationpip._vendor.rich._win32_consoler"pip._vendor.rich._windows_rendererr writerUnicodeEncodeErrorreasonflush) r~ruse_legacy_windows_renderrr rr(rrrararbrhsV           zConsole._check_buffer)rrzc Cszg}|j}|j}|j}|j }|jr2|r2t|}|D]4\}}} |rZ||j|||dq6|rb| s6||q6d|} | S)z)Render buffered output, and clear buffer.)r rnr) rnr5rnrqrrA remove_colorr6r) r~routputrnr rn not_terminalrrrrenderedrararbrs(    zConsole._render_buffer)rxrpasswordstream)promptrxrr1r2rzcCs@|r|j|||dd|r(td|d}n|r6|}nt}|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)rxrr)r2)rrreadlineinput)r~r3rxrr1r2resultrararbr5s z Console.inputrr)rrrzc Csf|jstd|jH|r2ddd|jD}nddd|jD}|rX|jdd=W5QRX|S)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 instancercss&|]\}}}|r||n|VqdSrr5)rrr_rararbr4sz&Console.export_text..css|]}|js|jVqdSr)rrrrararbr9sN)rrr?rrB)r~rrrrararb export_text"s    zConsole.export_text)rrrrzc Cs6|j||d}t|ddd}||W5QRXdS)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``. r7wtrzrrN)r:openr()r~rrrr write_filerararb save_textBs zConsole.save_textrr code_format inline_styles)rrrArBrzc Cs|jstdg}|j}|pt}d}|dkr0tn|} |j~|rtt|j D]\\} } } t | } | r| |} | j rd| j d| d} | rd| d| dn| } || qTni}tt|j D]t\} } } t | } | r6| |} | | t|d }| j r$d |d | j d| d} nd |d| d} || qg}|j}|D]&\}}|rR|d |d|dqRd|}| jd|||jj|jjd}|r|j dd=W5QRX|S)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. r8rNz zz rararb save_htmlszConsole.save_htmlRichrrrrA)rrrrArzc0sddlm}ittdfdd }|p,t|jd}|d|dd }d } d } d } d } d } d }d }|| }| |}| | }|| }g}g}i}d }ttd d d}d7tttttddd|j$t t |j }|r|j W5QRXdttddd|Ddd|ddd}tt j|dD]p\}}d}|D]Z\}}}|pft}||} | |kr||| <|d 7}d|| }!|jrd}"|jdkrjjn |jj}#n:|j}$|$dk o|$j }"|jdkrjjn |jj}#||}%|"r@|d|#||d|%ddd |d!t|kr|d"||d#|!|||t|d$d%|d&d'|||7}qPq>fd(d)t|D}&d*fd+dt|&D}'d*fd,d|D}(d|})d|}*t |}+|d |},djjd-d.| ||+|,d d/ }-jj}.|r|-d"||d0|.d1|+d2||d3d47}-|-d57}-|j!|d |d d |+||,|| ||| |(|-|)|*|'d6}/|/S)8a Generate an SVG from the console contents (requires record=True in Console constructor). Args: path (str): The path to write the SVG to. title (str): 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): 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. r)cell_len)rrzcs|kr|Sg}|jdks&|jjr,jn |j}|jdksJ|jjrPjn |j}|jrl||}}|jr~t||d}| d|j |j r| d|j r| d|j r| d|jr| dd|}||<|S) z%Convert a Style to CSS rules for SVG.Ng?zfill: zfont-weight: boldzfont-style: italic;ztext-decoration: underline;ztext-decoration: line-through;;)color is_defaultrM get_truecolorbgcolorrOreversedimr0rnrNbolditalic underlinestriker)r css_rulesr_rbcss)rQ style_cacherarb get_svg_styles>         z)Console.export_svg..get_svg_stylegQ?gQ?r%(r!)rrzcSst|ddS)z.HTML escape text and replace spaces with nbsp.rIz )r replacerrararb escape_text sz'Console.export_svg..escape_textN)rrattribsrzc s`ttddddfdd|D}|rNd|d|d|d |d Sd|d|d S) z.Make a tag from name, content, and attributes.rTcSst|trt|dSt|S)Ng)rfloatrLr)rUrararb stringify s  z7Console.export_svg..make_tag..stringifyrIc3s4|],\}}|dddd|dVqdS)r9rZz=""N)lstripro)rkvrtrarbr sz7Console.export_svg..make_tag..rrJz)objectrrr)rrrq tag_attribsraryrbmake_tag s z$Console.export_svg..make_tagz terminal-rcss|] }|jVqdSrrrrararbr. sz%Console.export_svg..rzr\)lengthrTrect?? crispEdges)fillrrrgrhshape_renderingrIrrZzurl(#-line-))_classrr textLength clip_pathcsg|]}|dqS)rra)rr) line_heightrarbrk sz&Console.export_svg..rc 3s@|]8\}}dd|ddd|dddVqdS) z rrr)rrrgrhz Nra)rrr) char_widthrr| unique_idrgrarbrl sc3s*|]"\}}dd|d|dVqdS).z-rz { z }Nra)rrjrule_no)rrarbrs szrgba(255,255,255,0.35)1)rstroke stroke_widthrrrgrhrxz-titlemiddlerc)rr text_anchorrrz )rr char_heightrterminal_widthterminal_heightrgrh terminal_x terminal_yrchrome backgroundsmatrixr)N)"pip._vendor.rich.cellsr]rBrrGrgrrzr?rrArHrBrzlibadler32rencoderrrcr_rMrNrarbr`rOrnrrangerr rL)0r~rrrrAr]rlr 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_norprrrrrrrrules class_namehas_backgroundrGrb text_length line_offsetsrrrrrrr title_colorsvgra)rQrrr|rkrrgrb export_svgs$ !                    zConsole.export_svg)rrrrrArzc Cs:|j||||d}t|ddd}||W5QRXdS)aGenerate 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): 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): 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. r\r;rzr<N)rr=r()r~rrrrrArr>rararbsave_svg szConsole.save_svg)NFF)r%)T)T)T)TN)N)N)r)N)rr)r)}r^r_r`rirenvironr rrrkr4rr"rrKrrjrCr2rr+rrrsrrKrrsetterrrArrSrLrVr/r6rrrkrlrrorqrrrrrrrrrxr rrrqr=rlrrfrmrrgrhrrrr9rrrrrrrrrrrr7rrr6rBrrrr rrrrrJr.rr1rrrrr>rrrr staticmethodr rrrrrrhrrr5r:r?rHrXr)rZr*rrrarararbrGsF #   x       -    ! !   6 ?  <  $ M    # e  A #   #% R= "  O " xr) svg_main_coderzcCstt|S)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 )rrrr)rrararb _svg_hash s r__main__)rzJSONRPC [i]request[/i]g?Fz2.0subtract*)minuend subtrahendr )Zjsonrpcrparamsidz Hello, World!z{'a': 1}z&Which one is correct team name in NBA?zNew York BullszLos Angeles KingszGolden State Warriorsz Huston Rocket)questionrZanswer)answeredq1z 5 + 7 = ? z 12 - 8 = ?)rrq2)ZsportZmaths)remptyZquiz)T)r r$rplatformrMr8rabcrr dataclassesrrr functoolsrrrYr r itertoolsr mathr timer typesrrrtypingrrrrrrrrrrrrrrr version_infor"r#r$Zpip._vendor.typing_extensionsrr&r'r(_export_formatr)r*r:r+r,rr-r.r_r/r0rr1rr2rr3r4rxr6rrr7r8rr9r:prettyr;r<protocolr=rr>scoper?rr@rrArrBrCstyledrEterminal_themerFrGrHrrIrJrrKrLrrMrirNrrPr+r,rrrr rrr]r __stdin__r" _STDIN_FILENO Exception __stdout___STDOUT_FILENO __stderr___STDERR_FILENOrr#r\rar`rfrlrrrrr;rrrrrrrrrrrr[r7rrylocalrrrrkrr rrr^rrreprrrarararbsH        D                       !'/!"