/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/rich
from typing import Optional, Tuple, Literal from ._loop import loop_last from .console import Console, ConsoleOptions, RenderableType, RenderResult from .control import Control from .segment import ControlType, Segment from .style import StyleType from .text import Text VerticalOverflowMethod = Literal["crop", "ellipsis", "visible"] class LiveRender: """Creates a renderable that may be updated. Args: renderable (RenderableType): Any renderable object. style (StyleType, optional): An optional style to apply to the renderable. Defaults to "". """ def __init__( self, renderable: RenderableType, style: StyleType = "", vertical_overflow: VerticalOverflowMethod = "ellipsis", ) -> None: self.renderable = renderable self.style = style self.vertical_overflow = vertical_overflow self._shape: Optional[Tuple[int, int]] = None def set_renderable(self, renderable: RenderableType) -> None: """Set a new renderable. Args: renderable (RenderableType): Any renderable object, including str. """ self.renderable = renderable def position_cursor(self) -> Control: """Get control codes to move cursor to beginning of live render. Returns: Control: A control instance that may be printed. """ if self._shape is not None: _, height = self._shape return Control( ControlType.CARRIAGE_RETURN, (ControlType.ERASE_IN_LINE, 2), *( ( (ControlType.CURSOR_UP, 1), (ControlType.ERASE_IN_LINE, 2), ) * (height - 1) ) ) return Control() def restore_cursor(self) -> Control: """Get control codes to clear the render and restore the cursor to its previous position. Returns: Control: A Control instance that may be printed. """ if self._shape is not None: _, height = self._shape return Control( ControlType.CARRIAGE_RETURN, *((ControlType.CURSOR_UP, 1), (ControlType.ERASE_IN_LINE, 2)) * height ) return Control() def __rich_console__( self, console: Console, options: ConsoleOptions ) -> RenderResult: renderable = self.renderable style = console.get_style(self.style) lines = console.render_lines(renderable, options, style=style, pad=False) shape = Segment.get_shape(lines) _, height = shape if height > options.size.height: if self.vertical_overflow == "crop": lines = lines[: options.size.height] shape = Segment.get_shape(lines) elif self.vertical_overflow == "ellipsis": lines = lines[: (options.size.height - 1)] overflow_text = Text( "...", overflow="crop", justify="center", end="", style="live.ellipsis", ) lines.append(list(console.render(overflow_text))) shape = Segment.get_shape(lines) self._shape = shape new_line = Segment.line() for last, line in loop_last(lines): yield from line if not last: yield new_line
.
Edit
..
Edit
LICENSE
Edit
__init__.py
Edit
__main__.py
Edit
__pycache__
Edit
_cell_widths.py
Edit
_emoji_codes.py
Edit
_emoji_replace.py
Edit
_export_format.py
Edit
_extension.py
Edit
_fileno.py
Edit
_inspect.py
Edit
_log_render.py
Edit
_loop.py
Edit
_null_file.py
Edit
_palettes.py
Edit
_pick.py
Edit
_ratio.py
Edit
_spinners.py
Edit
_stack.py
Edit
_timer.py
Edit
_win32_console.py
Edit
_windows.py
Edit
_windows_renderer.py
Edit
_wrap.py
Edit
abc.py
Edit
align.py
Edit
ansi.py
Edit
bar.py
Edit
box.py
Edit
cells.py
Edit
color.py
Edit
color_triplet.py
Edit
columns.py
Edit
console.py
Edit
constrain.py
Edit
containers.py
Edit
control.py
Edit
default_styles.py
Edit
diagnose.py
Edit
emoji.py
Edit
errors.py
Edit
file_proxy.py
Edit
filesize.py
Edit
highlighter.py
Edit
json.py
Edit
jupyter.py
Edit
layout.py
Edit
live.py
Edit
live_render.py
Edit
logging.py
Edit
markup.py
Edit
measure.py
Edit
padding.py
Edit
pager.py
Edit
palette.py
Edit
panel.py
Edit
pretty.py
Edit
progress.py
Edit
progress_bar.py
Edit
prompt.py
Edit
protocol.py
Edit
py.typed
Edit
region.py
Edit
repr.py
Edit
rule.py
Edit
scope.py
Edit
screen.py
Edit
segment.py
Edit
spinner.py
Edit
status.py
Edit
style.py
Edit
styled.py
Edit
syntax.py
Edit
table.py
Edit
terminal_theme.py
Edit
text.py
Edit
theme.py
Edit
themes.py
Edit
traceback.py
Edit
tree.py
Edit